2. Schedule
● Farrel Lifson
● Luke Randall
● Glenn Roberts
● John Anderson
● Marc Helligers
● Dave Ungerer
● YOU!(?)
3. Cape Town Ruby Brigade
●
Meet 2nd Wednesday of the Month
● 19:00
● At the Bandwidth Barn
“Just like Rubyfuza, except there's only one
talk, 1/10 of the people but yet the same
amount of drinking”
4. Cape Town Ruby Brigade
●
9th March
●
13th April - “Sinatra” - Clive Crous
●
11th May
●
9th June
●
13th July
●
10th August
●
14th September
●
12th October
●
9th November
8. to_s
● What? Convert to a string
● Why? To represent or label an object
● Where? In a textual context
● How? By leaving out almost all detail
Remember it's a label not a data dump!
9. to_s
● Person class with name, surname, DOB,
earnings, address, etc etc etc.
● to_s should leave out 98% of data because it's
not needed to represent the person!
def to_s
“#{ name } #{ surname }”
end
10. to_s
Dear <%= @person %>
<%= select(:person, @people.map{|p| [p, p.id]})%>
In the “standard” context a string representation of
a Person is their name.
12. inspect
● What? Convert to a string!
● Why? To represent or label an object
● Where? In a debugging/informative context!
● How? By leaving out most detail!
Label and identify the object.
13. inspect
def inspect
“#{ self }(#{ self.id })”
end
>Brand.all
=> [Nandos(9), KFC(4)]
Representation is good enough!
14. Inspect & collections
> t = TemperatureMonitor.find_by_geocode(“CPTN”)
=> Temperature Monitor: Cape Town
Latt: -33.96 Long: 18.59 Alt: 42m
Last 5 temperature readings(51 total):
17/9/2008: 18C
18/9/2008: 23C
19/9/2008: 22C
20/9/2008: 16C
21/9/2008: 15C
> t.readings.last
=> 17/5/2006: 17C