class Fonecal::GrandPrix
Attributes
circuit[RW]
events[RW]
Public Class Methods
new(eventWebsite)
click to toggle source
# 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
Public Instance Methods
city()
click to toggle source
# File lib/fonecal/grand_prix.rb, line 28 def city @circuit.city end
country()
click to toggle source
# File lib/fonecal/grand_prix.rb, line 32 def country location.country end
grandPrix()
click to toggle source
# File lib/fonecal/grand_prix.rb, line 48 def grandPrix "#{country} GP" # Belgian Grand Prix end
location()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/fonecal/grand_prix.rb, line 36 def timezone @timezone ||= Timezone::Zone.new :latlon => location.geometry["location"].values end
Private Instance Methods
createEvents()
click to toggle source
# File lib/fonecal/grand_prix.rb, line 55 def createEvents @crawler.timeTables.each do |day| day[:sessions].each do |event| type = event[:type] event[:date] = day[:date] if ['practice 1', 'practice 2', 'practice 3'].include?(type.downcase) @events << Practice.new(event, timezone) elsif type == "Qualifying" @events << Qualifying.new(event, timezone) elsif type == "Race" @events << Race.new(event, timezone) end end end end