Class: WrocLove::Airport
- Inherits:
-
Struct
- Object
- Struct
- WrocLove::Airport
- Defined in:
- lib/wroc_love/airport.rb
Constant Summary collapse
- TimeFormatRule =
"%y%m%d".freeze
Class Attribute Summary collapse
-
.airports ⇒ Object
Returns the value of attribute airports.
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.airports ⇒ Object
Returns the value of attribute airports.
9 10 11 |
# File 'lib/wroc_love/airport.rb', line 9 def airports @airports end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
4 5 6 |
# File 'lib/wroc_love/airport.rb', line 4 def code @code end |
#location ⇒ Object
Returns the value of attribute location
4 5 6 |
# File 'lib/wroc_love/airport.rb', line 4 def location @location end |
#name ⇒ Object
Returns the value of attribute 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
#description ⇒ Object
24 25 26 |
# File 'lib/wroc_love/airport.rb', line 24 def description "#{code.rjust(5)} #{name.rjust(35)} #{link}" end |
#link ⇒ Object
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 |