Your SlideShare is downloading. ×
Farrel Lifson
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Farrel Lifson

290
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
290
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Cape Town Ruby BrigadeLightning Talks!
  • 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 theres 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
  • 5. to_s & inspect: Wherefore art thou? Farrel Lifson farrel.lifson@aimred.com http://www.aimred.com
  • 6. inspect & to_sUsed to display an object
  • 7. inspect & to_sinspect - IRb/Consoleto_s – Everywhere else
  • 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 its 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 its not needed to represent the person!def to_s “#{ name } #{ surname }”end
  • 10. to_sDear <%= @person %><%= select(:person, @people.map{|p| [p, p.id]})%>In the “standard” context a string representation of a Person is their name.
  • 11. inspect> brands = Brand.all => [#<Brand id: 9, client_id: 8, name: "15 onOrange", benchmark_standards_score: 90,benchmark_satisfaction_score: 90,required_report_writing_grading: "A",required_demographic: "A", active: true,created_at: "2010-05-26 13:37:04", updated_at:"2010-05-26 13:37:04", visit_type_id: nil,report_template_code: 1, turnaround_time: 2>,#<Brand id: 4, client_id: 4, name: "Cape TownTourism", benchmark_standards_score: 80, ??????????benchmark_satisfaction_score: 80,required_report_writing_grading: "D"
  • 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. inspectdef 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
  • 15. inspect>Area.new(:area_desc => "Cape Town", :geocodes => "CPTN" )=>.---------------------------.|AREA ||---------------------------||Area Description: Cape Town||Geocodes: ["CPTN"] |---------------------------
  • 16. Limitations & Considerations● to_s – short – single line● inspect – 80x25 screen – Be wary of collections