SlideShare a Scribd company logo
1 of 16
Download to read offline
Cape Town Ruby Brigade




Lightning Talks!
Schedule
●   Farrel Lifson
●   Luke Randall
●   Glenn Roberts
●   John Anderson
●   Marc Helligers
●   Dave Ungerer
●   YOU!(?)
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”
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
to_s & inspect: Wherefore art thou?



              Farrel Lifson

        farrel.lifson@aimred.com

         http://www.aimred.com
inspect & to_s




Used to display an object
inspect & to_s



inspect - IRb/Console

to_s – Everywhere else
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!
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
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.
inspect
> brands = Brand.all
 => [#<Brand id: 9, client_id: 8, name: "15 on
Orange", 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 Town
Tourism", benchmark_standards_score: 80,


  ??????????
benchmark_satisfaction_score: 80,
required_report_writing_grading: "D"
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.
inspect
def inspect
  “#{ self }(#{ self.id })”
end


>Brand.all
 => [Nandos(9), KFC(4)]

      Representation is good enough!
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
inspect
>Area.new(:area_desc => "Cape Town",
          :geocodes => "CPTN" )
=>
.---------------------------.
|AREA                       |
|---------------------------|
|Area Description: Cape Town|
|Geocodes:         ["CPTN"] |
'---------------------------'
Limitations & Considerations
●   to_s
       –   short
       –   single line
●   inspect
       –   80x25 screen
       –   Be wary of collections

More Related Content

Similar to Farrel Lifson

Shipping your product overseas!
Shipping your product overseas!Shipping your product overseas!
Shipping your product overseas!Diogo Busanello
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsViget Labs
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsBen Scofield
 
Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Jordi Valverde
 
Metadata and the Power of Pattern-Finding
Metadata and the Power of Pattern-FindingMetadata and the Power of Pattern-Finding
Metadata and the Power of Pattern-FindingDATAVERSITY
 
Adding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug GrallAdding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug GrallSpark Summit
 
From Zero to DevOps Superhero: The Container Edition (Build 2019)
From Zero to DevOps Superhero: The Container Edition (Build 2019)From Zero to DevOps Superhero: The Container Edition (Build 2019)
From Zero to DevOps Superhero: The Container Edition (Build 2019)Jessica Deen
 
It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.Alex Powers
 
Virtual enterprise synthesys
 Virtual enterprise synthesys Virtual enterprise synthesys
Virtual enterprise synthesysVictor Romanov
 
Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...
Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...
Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...dev2ops
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersVitomir Kovanovic
 
Euro python 2015 writing quality code
Euro python 2015   writing quality codeEuro python 2015   writing quality code
Euro python 2015 writing quality coderadek_j
 
Introduction to SQL Server Graph DB
Introduction to SQL Server Graph DBIntroduction to SQL Server Graph DB
Introduction to SQL Server Graph DBGreg McMurray
 
The intersection of business rules and big data.
The intersection of business rules and big data.The intersection of business rules and big data.
The intersection of business rules and big data.Anurag Saran
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Tablesapdocs. info
 
03 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp0203 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp02tabish
 
03 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp0103 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp01wingsrai
 
How to generate a 100+ page website using parameterisation in R
How to generate a 100+ page website using parameterisation in RHow to generate a 100+ page website using parameterisation in R
How to generate a 100+ page website using parameterisation in RPaul Bradshaw
 

Similar to Farrel Lifson (20)

Shipping your product overseas!
Shipping your product overseas!Shipping your product overseas!
Shipping your product overseas!
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Ruby DSL
Ruby DSLRuby DSL
Ruby DSL
 
Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011
 
Metadata and the Power of Pattern-Finding
Metadata and the Power of Pattern-FindingMetadata and the Power of Pattern-Finding
Metadata and the Power of Pattern-Finding
 
Adding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug GrallAdding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug Grall
 
PythonCERR_2014
PythonCERR_2014PythonCERR_2014
PythonCERR_2014
 
From Zero to DevOps Superhero: The Container Edition (Build 2019)
From Zero to DevOps Superhero: The Container Edition (Build 2019)From Zero to DevOps Superhero: The Container Edition (Build 2019)
From Zero to DevOps Superhero: The Container Edition (Build 2019)
 
It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.
 
Virtual enterprise synthesys
 Virtual enterprise synthesys Virtual enterprise synthesys
Virtual enterprise synthesys
 
Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...
Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...
Without Self-Service Operations, the Cloud is Just Expensive Hosting 2.0 - (a...
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 
Euro python 2015 writing quality code
Euro python 2015   writing quality codeEuro python 2015   writing quality code
Euro python 2015 writing quality code
 
Introduction to SQL Server Graph DB
Introduction to SQL Server Graph DBIntroduction to SQL Server Graph DB
Introduction to SQL Server Graph DB
 
The intersection of business rules and big data.
The intersection of business rules and big data.The intersection of business rules and big data.
The intersection of business rules and big data.
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
 
03 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp0203 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp02
 
03 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp0103 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp01
 
How to generate a 100+ page website using parameterisation in R
How to generate a 100+ page website using parameterisation in RHow to generate a 100+ page website using parameterisation in R
How to generate a 100+ page website using parameterisation in R
 

Farrel Lifson

  • 1. Cape Town Ruby Brigade Lightning 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 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
  • 5. to_s & inspect: Wherefore art thou? Farrel Lifson farrel.lifson@aimred.com http://www.aimred.com
  • 6. inspect & to_s Used to display an object
  • 7. inspect & to_s inspect - IRb/Console to_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 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.
  • 11. inspect > brands = Brand.all => [#<Brand id: 9, client_id: 8, name: "15 on Orange", 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 Town Tourism", 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. 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
  • 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