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



30
31
32
# File 'lib/fonecal/grand_prix.rb', line 30

def city
  @circuit.city
end

#countryObject



34
35
36
# File 'lib/fonecal/grand_prix.rb', line 34

def country
  location.country
end

#grandPrixObject



46
47
48
49
# File 'lib/fonecal/grand_prix.rb', line 46

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

#locationObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# 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

  #@location ||= Geocoder.search("#{@circuit.name}, #{@circuit.city}").first
end

#raceTitleObject



42
43
44
# File 'lib/fonecal/grand_prix.rb', line 42

def raceTitle 
  @crawler.gp.gsub(/\w+/).map(&:capitalize).join(' ')
end

#timezoneObject



38
39
40
# File 'lib/fonecal/grand_prix.rb', line 38

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