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
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
430
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
230
CSC305 Lecture 25
javiergs
PRO
0
130
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
선언형 UI에서의 상태관리
l2hyunwoo
0
150
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
300
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
Security_for_introducing_eBPF
kentatada
0
110
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
CSC305 Lecture 26
javiergs
PRO
0
140
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
310
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Practical Orchestrator
shlominoach
186
10k
A better future with KSS
kneath
238
17k
Designing Experiences People Love
moore
138
23k
Building Applications with DynamoDB
mza
91
6.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
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/
͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠