Class: WrocLove::Airport

Inherits:
Struct
  • Object
show all
Defined in:
lib/wroc_love/airport.rb

Constant Summary collapse

TimeFormatRule =
"%y%m%d".freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.airportsObject

Returns the value of attribute airports.



9
10
11
# File 'lib/wroc_love/airport.rb', line 9

def airports
  @airports
end

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



4
5
6
# File 'lib/wroc_love/airport.rb', line 4

def code
  @code
end

#locationObject

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



4
5
6
# File 'lib/wroc_love/airport.rb', line 4

def location
  @location
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/wroc_love/airport.rb', line 4

def name
  @name
end

Class Method Details

.nearest(location, count = 10) ⇒ Object



16
17
18
# File 'lib/wroc_love/airport.rb', line 16

def nearest(location, count = 10)
  airports.sort_by{|a| Geocoder::Calculations.distance_between(a.location, location) }.first(count)
end

.store(*params) ⇒ Object



12
13
14
# File 'lib/wroc_love/airport.rb', line 12

def store(*params)
  airports << new(*params).freeze
end

Instance Method Details

#descriptionObject



24
25
26
# File 'lib/wroc_love/airport.rb', line 24

def description
  "#{code.rjust(5)}    #{name.rjust(35)}     #{link}"
end


28
29
30
# File 'lib/wroc_love/airport.rb', line 28

def link
  "http://www.skyscanner.net/flights/#{code.downcase}/wro/#{WrocLove::Arrival.strftime(TimeFormatRule)}/#{WrocLove::Return.strftime(TimeFormatRule)}"
end