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
Ruby by Example
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
James Hughes
June 22, 2012
Programming
590
7
Share
Ruby by Example
James Hughes
June 22, 2012
More Decks by James Hughes
See All by James Hughes
Functional Programming with Clojure
kouphax
1
150
Tyrannosaurus Rx
kouphax
0
130
React
kouphax
2
750
Play for (Java|Scala)
kouphax
0
150
Devops: A Case Study
kouphax
0
99
Scala for C# Developers
kouphax
5
2.7k
Dropwizard - Production Ready Web Services
kouphax
3
1.7k
Scala for Fun & Profit
kouphax
4
660
What Agile Means To Me
kouphax
0
170
Other Decks in Programming
See All in Programming
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
1
540
Running Swift without an OS
kishikawakatsumi
0
870
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
510
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
250
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
190
Import assertionsが消えた日~ECMAScriptの仕様はどう決まり、なぜ覆るのか~
bicstone
2
160
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
25
17k
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
210
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
19
9.1k
書き換えて学ぶTemporal #fukts
pirosikick
2
320
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.1k
Featured
See All Featured
Marketing to machines
jonoalderson
1
5.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
350
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Six Lessons from altMBA
skipperchong
29
4.2k
Accessibility Awareness
sabderemane
1
110
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
The Language of Interfaces
destraynor
162
26k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
160
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
Joys of Absence: A Defence of Solitary Play
codingconduct
1
360
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