Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
#UV_study_20210629
Search
Shiro Tamaki
June 29, 2021
Programming
0
250
#UV_study_20210629
【初心者歓迎】Ruby LT会@オンライン \- connpass
(
https://uniquevision.connpass.com/event/215217/
)
Shiro Tamaki
June 29, 2021
Tweet
Share
More Decks by Shiro Tamaki
See All by Shiro Tamaki
kakutanitalk2022_opening_act
shirotamaki
0
750
fjordbootcamp_20210424
shirotamaki
0
950
fjordbootcamp_20210424_mc_slide
shirotamaki
0
800
Other Decks in Programming
See All in Programming
たのしいparse.y
ydah
3
120
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
290
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
Zoneless Testing
rainerhahnekamp
0
120
Refactor your code - refactor yourself
xosofox
1
260
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
330
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
470
Security_for_introducing_eBPF
kentatada
0
110
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
KATA
mclloyd
29
14k
Docker and Python
trallard
42
3.1k
Gamification - CAS2011
davidbonilla
80
5.1k
Designing Experiences People Love
moore
138
23k
Automating Front-end Workflow
addyosmani
1366
200k
Code Review Best Practice
trishagee
65
17k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Unsuck your backbone
ammeep
669
57k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Transcript
1 SinatraΛͬͯ ॳΊͯWebΞϓϦΛ࡞ͬͯΈͨ @shirotamaki 2021, 6, 29 (Tue) ɹRuby LTձ@ΦϯϥΠϯ
ओ࠵ : ϢχʔΫϏδϣϯגࣜձ༷ࣾ ʮRubyΫοΩϯάʯ
˙͘͡ 2 • ࣗݾհ • ࡞ΔϝχϡʔɺࡐྉͳͲͷհ • ࡐྉʹ͍ͭͯਂງΓ • ࡞Γํ
˙ࣗݾհ @shirotamaki ɹ ۄ ࢤ ϑΟϤϧυϒʔτΩϟϯϓ32ظੜ Rubyྺ: 6ϲ݄ 3
˙RubyͰ࡞Δϝχϡʔ 4 JSONͱHashΛͬͨSinatra࢈ ϝϞΞϓϦ
˙ࡐྉ * JSONϑΝΠϧ * HashΦϒδΣΫτ 5 ˙༻ҙ͢Δͷ • Ruby 3.0.0
• Sinatra
˙ௐຯྉ * params ϋογϡ ɹ * JSON.parseϞδϡʔϧؔ * JSON.dumpϞδϡʔϧؔ 6
˙ਂງΓ
˙Sinatraʢγφτϥʣ 8 RubyͷWebΞϓϦέʔγϣϯϑϨʔϜϫʔΫͰ͢ɻ هड़༰͕؆ܿͰ͔Γ͘͢ͱ͍ͯܰͷ͕ಛͰ͢ɻ ͦͷͨΊɺখنͳΞϓϦέʔγϣϯΛ࡞͢Δͷʹ ͍͍ͯ·͢ɻ
˙JSONʢδΣΠιϯʣ 9 JavaScript Object Notationͷུ ߏԽͨ͠σʔλΛදͨ͢ΊͷςΩετϑΥʔϚοτͷҰछͰ͢ɻ JavaScript͚ͩͰͳ͘ɺଟ͘ͷϓϩάϥϛϯάݴޠWebαʔϏε ʹରԠ͍ͯ͠·͢ɻ ઃఆϑΝΠϧσʔλަͳͲΛ͢Δͱ͖ʹΑ͘ΘΕ͍ͯ·͢ɻ ϑΝΠϧ໊ʮKTPOʯɹ
˞σʔλϕʔεͷཧJSONϑΝΠϧΛར༻͠·͢ɻ ɹࠓճɺActiveRecordར༻͠·ͤΜɻ
˙JSON͕ରԠ͍ͯ͠Δσʔλܕ 10 JSONʹΈࠐΈͰ༻ҙ͞Ε͍ͯΔσʔλܕ̒ͭ * ΦϒδΣΫτ * ྻ * จࣈྻ *
* ϒʔϦΞϯ * null
˙Hashʢϋογϡʣ 11 ϋογϡɺʮΩʔʯͱʮʯͷηοτͰσʔλΛཧ͢Δ ΦϒδΣΫτͷ͜ͱͰ͢ɻ ଞͷݴޠͰʮ࿈ྻʯʮࣙॻʯʮϚοϓʯͱݺΕͨΓ ͠·͢ɻ ӳޠͷHashɺίϚΕͱࡊΛᖱΊͨྉཧͷࣄΛࢦ͠ɺ ϋογϡυϏʔϑͷޠݯͰ͋Γ·͢ɻ
˙Hashͷ2ͭͷॻ͖ํ 12 ϋογϡϩέοτ ͬͨॻ͖ํ ϋογϡϩέοτΛলུͨ͠ॻ͖ํ
˙Ruby ΫοΩϯάελʔτʂ 13
14 ˙·ͣɺrequireͰԼ͝͠Β͑
˙৽نϝϞೖྗը໘ͷϧʔςΟϯά 15
˙ڞ௨͢ΔϨΠΞτΛ·ͱΊΔ 16 index.erb new.erb
17 ˙formλάͰೖྗɾૹ৴ϑΥʔϜΛ࡞͢Δ
˙్தܦաɺHTMLΛϨϯμϦϯάʢը૾Λੜʣ 18
˙HashΛJSONม͠ϑΝΠϧΛอଘ͢Δ 19 JSON Hash JSON.dump
˙JSONϑΝΠϧͱͯ͠ɺdbσΟϨΫτϦอଘ͢Δ 20
˙ϝϞҰཡදࣔ༻ͷϧʔςΟϯά 21 JSON Hash JSON.parse
˙Ұཡදࣔ༻ͷerbΛ࡞͢Δ 22
˙πϦʔߏ 23
˙URLΞΫηεͯ͠ΈΔ 24
˙ग़དྷ্͕Γʂ 25
˙ࢀߟهࣄɾࢀߟॻ੶ 26 ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ https:/ /docs.ruby-lang.org/ja/(ࢀর2021,6,28) Sinatra: README http:/
/sinatrarb.com/intro-ja.html/(ࢀর2021.6.28) ϦϒϩϫʔΫε ஶ/ߴڮ ٛ म/ʰεϥεϥಡΊΔ Ruby;Γ͕ͳϓϩάϥϛϯά ʱ/ΠϯϓϨεϒοΫε/2019 ޒेཛྷ໌ɼদԬߒฏ ஶ/ʰθϩ͔ΒΘ͔Δ Ruby ೖʱ/ٕज़ධࣾ/2018 ߴڮٛɺޙ౻༟ଂ ஶ/ʰͨͷ͍͠Rubyୈ6൛ʱ/SBΫϦΤΠςΟϒ/2019 ҏ౻३Ұ ஶ/ʰϓϩΛࢦ͢ਓͷͨΊͷRubyೖ ݴޠ༷͔Βςετۦಈ։ൃɾσόοάٕ๏·Ͱʱ/ٕज़ධࣾ/ 2017 ࢁຊཅฏஶ/ ʰWebΛࢧ͑Δٕज़ɹHTTP, URI, HTML, ͦͯ͠RESTʱ/ٕज़ධࣾ/2010
˙ϒϩάͬͯ·͢ 27 ͯͳϒϩά D IT YɹλϚΩళͷITه https:/ /shirotamaki.hatenablog.com/
͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠