Module: Airports
- Defined in:
- lib/airports.rb,
lib/airports/airport.rb,
lib/airports/version.rb
Defined Under Namespace
Classes: Airport
Constant Summary collapse
- VERSION =
"1.10.0"
Class Method Summary collapse
- .all ⇒ Object
- .find_all_by_city_name(city_name) ⇒ Object
- .find_all_by_country_name(country_name) ⇒ Object
- .find_by_iata_code(iata_code) ⇒ Object
- .find_by_icao_code(icao_code) ⇒ Object
- .iata_codes ⇒ Object
- .icao_codes ⇒ Object
- .parsed_data ⇒ Object
Class Method Details
.all ⇒ Object
36 37 38 39 40 |
# File 'lib/airports.rb', line 36 def self.all @all ||= parsed_data.values.map do |airport_data| airport_from_parsed_data_element(airport_data) end end |
.find_all_by_city_name(city_name) ⇒ Object
20 21 22 |
# File 'lib/airports.rb', line 20 def self.find_all_by_city_name(city_name) all.select { |airport| airport.city.casecmp(city_name).zero? } end |
.find_all_by_country_name(country_name) ⇒ Object
24 25 26 |
# File 'lib/airports.rb', line 24 def self.find_all_by_country_name(country_name) all.select { |airport| airport.country.casecmp(country_name).zero? } end |
.find_by_iata_code(iata_code) ⇒ Object
8 9 10 11 12 |
# File 'lib/airports.rb', line 8 def self.find_by_iata_code(iata_code) return unless iata_code.length == 3 all.find { |airport| airport.iata == iata_code } end |
.find_by_icao_code(icao_code) ⇒ Object
14 15 16 17 18 |
# File 'lib/airports.rb', line 14 def self.find_by_icao_code(icao_code) return unless icao_code.length == 4 all.find { |airport| airport.icao == icao_code } end |
.iata_codes ⇒ Object
28 29 30 |
# File 'lib/airports.rb', line 28 def self.iata_codes parsed_data.keys end |
.icao_codes ⇒ Object
32 33 34 |
# File 'lib/airports.rb', line 32 def self.icao_codes parsed_data.values.map { |airport_data| airport_data["icao"] } end |
.parsed_data ⇒ Object
42 43 44 |
# File 'lib/airports.rb', line 42 def self.parsed_data @parsed_data ||= JSON.parse(data) end |