Class: Fonecal::GrandPrix
- Inherits:
-
Object
- Object
- Fonecal::GrandPrix
- Defined in:
- lib/fonecal/grand_prix.rb
Instance Attribute Summary collapse
-
#circuit ⇒ Object
Returns the value of attribute circuit.
-
#events ⇒ Object
Returns the value of attribute events.
Instance Method Summary collapse
- #city ⇒ Object
- #country ⇒ Object
- #grandPrix ⇒ Object
-
#initialize(eventWebsite) ⇒ GrandPrix
constructor
A new instance of GrandPrix.
- #location ⇒ Object
- #raceTitle ⇒ Object
- #timezone ⇒ Object
Constructor Details
#initialize(eventWebsite) ⇒ GrandPrix
Returns a new instance of GrandPrix.
8 9 10 11 12 13 14 |
# File 'lib/fonecal/grand_prix.rb', line 8 def initialize(eventWebsite) @crawler = EventCrawler.new(eventWebsite) self.circuit= CircuitInfo.new(@crawler.circuitInfo) self.events = [] createEvents end |
Instance Attribute Details
#circuit ⇒ Object
Returns the value of attribute circuit.
6 7 8 |
# File 'lib/fonecal/grand_prix.rb', line 6 def circuit @circuit end |
#events ⇒ Object
Returns the value of attribute events.
6 7 8 |
# File 'lib/fonecal/grand_prix.rb', line 6 def events @events end |
Instance Method Details
#city ⇒ Object
28 29 30 |
# File 'lib/fonecal/grand_prix.rb', line 28 def city @circuit.city end |
#country ⇒ Object
32 33 34 |
# File 'lib/fonecal/grand_prix.rb', line 32 def country location.country end |
#grandPrix ⇒ Object
48 49 50 51 |
# File 'lib/fonecal/grand_prix.rb', line 48 def grandPrix "#{country} GP" # Belgian Grand Prix end |
#location ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fonecal/grand_prix.rb', line 16 def location if @res ||= Geocoder.search("#{@circuit.name}, #{@circuit.city}").first @res elsif @res ||= Geocoder.search("#{@circuit.city}").first @res elsif res ||= Geocoder.search("#{@circuit.name}").first @res else @res end end |
#raceTitle ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/fonecal/grand_prix.rb', line 40 def raceTitle title = @crawler.gp.split(/(\W)/).map(&:capitalize).join # Dirty decapitalization hack title = title.gsub(/Í/, 'í') title = title.gsub(/J/, 'j') end |
#timezone ⇒ Object
36 37 38 |
# File 'lib/fonecal/grand_prix.rb', line 36 def timezone @timezone ||= Timezone::Zone.new :latlon => location.geometry["location"].values end |