Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ruby by Example
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
James Hughes
June 22, 2012
Programming
610
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby by Example
James Hughes
June 22, 2012
More Decks by James Hughes
See All by James Hughes
Functional Programming with Clojure
kouphax
1
170
Tyrannosaurus Rx
kouphax
0
140
React
kouphax
2
760
Play for (Java|Scala)
kouphax
0
170
Devops: A Case Study
kouphax
0
120
Scala for C# Developers
kouphax
5
2.7k
Dropwizard - Production Ready Web Services
kouphax
3
1.7k
Scala for Fun & Profit
kouphax
4
680
What Agile Means To Me
kouphax
0
190
Other Decks in Programming
See All in Programming
Simple Storage Service(S3) is not simple
iwatsukayura
0
280
ジョジョの世界をXRで再現する
mofurune
0
160
Kotlinの15年とServer-Side Kotlin
n_takehata
1
140
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
780
Workers Cache を知る
syumai
0
360
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
130
最近”作らせてる” ローカルAIアプリの話
akit37
0
460
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
170
気持ちぃ〜角丸 Squircle
ryu1013
0
300
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Optimizing for Happiness
mojombo
378
71k
Balancing Empowerment & Direction
lara
6
1.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Become a Pro
speakerdeck
PRO
31
6.3k
Paper Plane (Part 1)
katiecoart
PRO
2
12k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
Transcript
RUBY BY EXAMPLE
Ruby is... interpreted object oriented dynamic
Ruby is... productive intuitive popular
VARIABLES & TYPES
Before we begin... a.+(b) a.is_valid? a.decrement!
$counter @@counter @counter counter Global Class Instance Local
‘hello’ ‘’‘hello’’’ %q{hello} String Herestring Perl-inspired
a = ‘James’ b = “Hello #{a}” puts b =>
“Hello James”
:hello Symbol
puts <<DOC This is a "heredoc" Multi-line String DOC
[1,2,3] {:a=>1, :b=>2} {a: 1, b: 2} 0..10 Array Hash
(1.8) Hash (1.9) Ranges
METHODS
def greet(name) “Hello, #{name}” end greet “James”
def greet(name=“World”) “Hello, #{name}” end greet “James” greet
CONTROL FLOW
if rating >= 4 puts "great" elsif rating == 3
puts "alright" else puts "sucks" end
unless rating == 5 puts “Try harder” end
puts “Try harder” unless rating == 5 puts “Seriously” if
rating == 1
case rating when 4..5 puts "great" when 3 puts "alright"
else puts "sucks" end
while !le.has_more_lines? puts !le.next_line end puts !le.next_line while !le.has_more_lines?
until !le.end_of_!le? puts !le.next_line end puts !le.next_line until !le.end_of_!le?
for i in 0...!le.line_count puts !le.lines[i] end
BLOCKS
[1,2,3,4].each do |i| puts i end
array.each(&block)
printer = Proc.new do |i| puts i end [1,2,3,4].each &printer
printer = lambda { |i| puts i }
def loggerWrapper puts "Executing Method" yield puts "Done Executing" end
loggerWrapper { puts "Weeee!" }
COLLECTIONS
Array/Enumerable Operations 109 Hash Operations 50
[1,2,3,4,5].map { |i| i +1} [1,2,3,4,5].reduce { |i, j| i
+ j } ({a: '1'}).merge({b: '2'})
CLASSES
class Person def initialize(name, age) @name,@age = name,age end end
person = Person.new("James", 32)
class Person attr_accessor :name attr_accessor :age ... end p =
Person.new("James", 32) puts p.name, p.age
class Person ... end class Hero < Person attr_accessor :powers
end p = Hero.new("James", 32) p.powers = [“Flying”]
MODULES & MIXINS
module StrUtils def self.salt(pass, slt) “#{pass}#{salt}” end def salt(slt) StrUtils::salt(@value,
slt) end end
StrUtils::salt("123", "456")
class Password include Utils def initialize(value) @value = value end
end Password.new("test").salt
TOOLS OF THE TRADE
irb Interactive shell ruby Ruby interpreter gem Library manager rake
Build tool rails Web framework
RUBY BY EXAMPLE