Class: Fonecal::GrandPrix

Inherits:
Object
  • Object
show all
Defined in:
lib/fonecal/grand_prix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#circuitObject

Returns the value of attribute circuit.



6
7
8
# File 'lib/fonecal/grand_prix.rb', line 6

def circuit
  @circuit
end

#eventsObject

Returns the value of attribute events.



6
7
8
# File 'lib/fonecal/grand_prix.rb', line 6

def events
  @events
end

Instance Method Details

#cityObject



28
29
30
# File 'lib/fonecal/grand_prix.rb', line 28

def city
  @circuit.city
end

#countryObject



32
33
34
# File 'lib/fonecal/grand_prix.rb', line 32

def country
  location.country
end

#grandPrixObject



48
49
50
51
# File 'lib/fonecal/grand_prix.rb', line 48

def grandPrix
  "#{country} GP"
  # Belgian Grand Prix
end

#locationObject



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

#raceTitleObject



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

#timezoneObject



36
37
38
# File 'lib/fonecal/grand_prix.rb', line 36

def timezone
  @timezone ||= Timezone::Zone.new :latlon => location.geometry["location"].values
end