-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathruby_for_beginners.html
347 lines (302 loc) · 10.7 KB
/
ruby_for_beginners.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head><meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>deck.rb presentation</title>
<meta charset="utf-8" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
<meta content="width=1024, user-scalable=no" name="viewport" />
<link href="deck.js/core/deck.core.css" rel="stylesheet" />
<link href="deck.js/extensions/goto/deck.goto.css" rel="stylesheet" />
<link href="deck.js/extensions/menu/deck.menu.css" rel="stylesheet" />
<link href="deck.js/extensions/navigation/deck.navigation.css" rel="stylesheet" />
<link href="deck.js/extensions/status/deck.status.css" rel="stylesheet" />
<link href="deck.js/extensions/hash/deck.hash.css" rel="stylesheet" />
<link href="deck.js/extensions/scale/deck.scale.css" rel="stylesheet" />
<link href="deck.js/themes/style/web-2.0.css" id="style-theme-link" rel="stylesheet" />
<link href="deck.js/themes/transition/horizontal-slide.css" id="transition-theme-link" rel="stylesheet" />
<link href="deck.js/introduction/introduction.css" rel="stylesheet" />
<script src="deck.js/modernizr.custom.js"></script>
</head>
<body class="deck-container">
<div class="theme-picker">
<h2>Themes</h2>
<label for="style-themes">Style:</label>
<select id="style-themes">
<option selected="selected" value="deck.js/themes/style/web-2.0.css">Web 2.0</option>
<option value="deck.js/themes/style/swiss.css">Swiss</option>
<option value="deck.js/themes/style/neon.css">Neon</option>
<option value="">None</option>
</select>
<label for="transition-themes">Transition:</label>
<select id="transition-themes">
<option selected="selected" value="deck.js/themes/transition/horizontal-slide.css">Horizontal Slide</option>
<option value="deck.js/themes/transition/vertical-slide.css">Vertical Slide</option>
<option value="deck.js/themes/transition/fade.css">Fade</option>
<option value="">None</option>
</select></div>
<section class="slide subsection" id="">
<h1>The Complete Beginner's Guide to Programming</h1>
</section>
<section class="slide" id="">
<h1>What is a program?</h1>
</section>
<section class="slide" id="operating_systems">
<h2>Operating Systems</h2>
<p><img src="img/os_x_logo.jpg" alt=""></p>
<p><img src="img/windows_logo.gif" alt=""></p>
<p><img src="img/linux_logo.gif" alt=""></p>
</section>
<section class="slide" id="applications">
<h2>Applications</h2>
<p><img src="img/acrobat.jpg" alt="">
<img src="img/finder.png" alt="">
<img src="img/firefox.png" alt="">
<img src="img/itunes.png" alt="">
<img src="img/quicktime.jpg" alt="">
<img src="img/safari.png" alt="">
<img src="img/ms_office.png" alt="">
<img src="img/wordpress.jpg" alt=""></p>
</section>
<section class="slide centereverything" id="">
<h2>Web Application In Rails</h2>
<p><img src="img/web_app_in_rails.jpg" alt=""></p>
</section>
<section class="slide incremental smbullets" id="how_do_i_write_one">
<h2>How do I write one?</h2>
<ul>
<li>Learn about customer's requirements</li>
<li>Translate to "stories"</li>
<li>Pick a story that seems doable</li>
<li>Write code that does it</li>
<li>Show your work to the customer, get feedback</li>
<li>Based on feedback, adjust your stories</li>
<li>When a story is done, go back to "pick a story"</li>
<li>Repeat until app is finished!</li>
</ul>
</section>
<section class="slide subsection" id="">
<h1>Let's start writing code!</h1>
</section>
<section class="slide bullets" id="">
<p>#* Windows: git bash <img src="img/git_bash.png" alt=""></p>
<ul>
<li>Mac OS X: Terminal <img src="img/mac_terminal_sm.png" alt=""></li>
</ul>
</section>
<section class="slide commandline" id="">
<p>#$ irb</p>
</section>
<section class="slide" id="">
<h3>Variables</h3>
<h3>words that hold information</h3>
<pre><code>> my_variable = 5
=> 5
> my_other_variable = "hi"
=> "hi"
</code></pre>
</section>
<section class="slide" id="types_of_information">
<h3>Types of information</h3>
</section>
<section class="slide" id="strings_text">
<h3>Strings (text)</h3>
</section>
<section class="slide" id="numbers">
<h3>Numbers</h3>
</section>
<section class="slide" id="collections">
<h1>Collections</h1>
</section>
<section class="slide" id="arrays">
<h2>Arrays</h2>
<p>An Array is a list of objects.</p>
<pre><code>>> fruits = ["kiwi", "strawberry", "plum"]
=> ["kiwi", "strawberry", "plum"]
</code></pre>
</section>
<section class="slide" id="array_indexing">
<h2>Array Indexing</h2>
<p>Ruby starts counting at zero.</p>
<pre><code>>> fruits[0]
=> "kiwi"
>> fruits[2]
=> "plum"
>> fruits[3]
=> nil
</code></pre>
</section>
<section class="slide" id="array_methods">
<h2>Array methods</h2>
<ul>
<li>first, last</li>
<li>push, pop</li>
<li><p>shift, unshift</p>
<pre><code>fruits.first #=> "kiwi"
</code></pre></li>
</ul>
</section>
<section class="slide" id="hashes">
<h2>Hashes</h2>
<ul>
<li>aka Dictionary or Map</li>
<li><p>collection of key/value pairs</p>
<pre><code>>> states = {"CA" => "California",
"DE" => "Delaware"}
=> {"CA"=>"California", "DE"=>"Delaware"}
>> states["CA"]
=> "California"
</code></pre></li>
</ul>
</section>
<section class="slide" id="operators">
<h3>Operators</h3>
<h3>doing stuff with variables</h3>
<pre><code>> my_variable + 2
=> 7
> my_variable * 3
=> 15
> my_fruits = my_fruits + ["lychee"]
=> ["kiwi", "strawberry", "plum", "lychee"]
> my_fruits = my_fruits - ["lychee"]
=> ["kiwi", "strawberry", "plum"]
</code></pre>
</section>
<section class="slide" id="loops">
<h2>Loops</h2>
<h3>doing the same thing a bunch of times</h3>
<p>The hard way:</p>
<pre><code>>> puts fruits[0]
kiwi
=> nil
>> puts fruits[1]
strawberry
=> nil
>> puts fruits[2]
plum
=> nil
</code></pre>
</section>
<section class="slide" id="loops">
<h2>Loops</h2>
<h3>doing the same thing a bunch of times</h3>
<p>The easy way:</p>
<pre><code>>> fruits.each {|f| puts f}
kiwi
strawberry
plum
=> ["kiwi", "strawberry", "plum"]
</code></pre>
</section>
<section class="slide" id="loops_multiline">
<h2>Loops (multi-line)</h2>
<p>The easy way, with "do...end" rather than "{...}"</p>
<pre><code>>> fruits.each do |f|
?> puts f
>> end
kiwi
strawberry
plum
=> ["kiwi", "strawberry", "plum"]
</code></pre>
</section>
<section class="slide" id="conditionals">
<h3>Conditionals</h3>
<h3>doing something only if a condition is met</h3>
<pre><code>>> fruits.each do |f|
?> puts f if f == "plum"
>> end
plum
=> ["kiwi", "strawberry", "plum"]
</code></pre>
</section>
<section class="slide subsection" id="commandline_programs">
<h1>Command-Line Programs</h1>
</section>
<section class="slide bullets" id="hello_world">
<h2>Hello World</h2>
<p>hello.rb
@@@ Ruby
puts "Hello, World!"</p>
</section>
<section class="slide bullets" id="arguments_argv">
<h2>Arguments (ARGV)</h2>
<p>hello.rb
@@@ Ruby
puts "Hello, #{ARGV.first}!"</p>
<pre><code>$ ruby hello.rb Alice
Hello, Alice!
</code></pre>
</section>
<section class="slide bullets" id="conditionals">
<h2>Conditionals</h2>
<p>hello.rb
@@@ Ruby
if ARGV.empty?
puts "Hello, World!"
else
puts "Hello, #{ARGV.first}!"
end</p>
<pre><code>$ ruby hello.rb
Hello, World!
$ ruby hello.rb Alice
Hello, Alice!
</code></pre>
</section>
<section class="slide" id="sinatra">
<h2>Sinatra</h2>
<h2>hello_app.rb</h2>
<pre><code>@@@ Ruby
require 'rubygems'
require 'sinatra'
get '/' do
"<b>Hello, <i>bang bang</i>!"
end
</code></pre>
</section>
<section class="slide commandline" id="sinatra">
<h2>Sinatra</h2>
<pre><code>$ gem install sinatra
$ ruby hello_app.rb
== Sinatra/1.2.6 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
</code></pre>
<p>then open a browser to <a href="http://localhost:4567/">http://localhost:4567/</a></p>
</section>
<section class="slide bullets" id="sinatra_with_rerun">
<h2>sinatra with rerun</h2>
<pre><code>gem install rerun
rerun hello_app.rb
</code></pre>
<p>...now it'll automatically reload when you edit a file.</p>
</section>
<section class="slide" id="web_app_network_architecture">
<h3>Web App Network Architecture</h3>
<p><img src="img/web-application.png" alt=""></p>
</section>
<section class="slide" id="web_app_mvc_architecture">
<h3>Web App MVC Architecture</h3>
<p><img src="img/mvc_simple.png" alt=""></p>
</section>
<a class="deck-prev-link" href="#" title="Previous"></a><a class="deck-next-link" href="#" title="Next"></a>
<p class="deck-status"><span class="deck-status-current"></span>/<span class="deck-status-total"></span></p>
<form action="." class="goto-form" method="get">
<label for="goto-slide">Go to slide:</label>
<input id="goto-slide" list="goto-datalist" name="slidenum" type="text" />
<datalist id="goto-datalist"></datalist>
<input type="submit" value="Go" /></form>
<a class="deck-permalink" href="." title="Permalink to this slide">#</a>
<script src="./deck.js/jquery-1.7.min.js"></script>
<!--Deck Core and extensions-->
<script src="deck.js/core/deck.core.js" type="text/javascript"></script>
<script src="deck.js/extensions/hash/deck.hash.js" type="text/javascript"></script>
<script src="deck.js/extensions/menu/deck.menu.js" type="text/javascript"></script>
<script src="deck.js/extensions/goto/deck.goto.js" type="text/javascript"></script>
<script src="deck.js/extensions/status/deck.status.js" type="text/javascript"></script>
<script src="deck.js/extensions/navigation/deck.navigation.js" type="text/javascript"></script>
<script src="deck.js/extensions/scale/deck.scale.js" type="text/javascript"></script>
<script src="deck.js/introduction/introduction.js"></script>
</body>
</html>