Skip to content

Commit

Permalink
Add class method for icao codes, spec
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnLawrence committed Nov 28, 2024
1 parent 719dc79 commit bd96675
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/airports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def self.iata_codes
parsed_data.keys
end

def self.icao_codes
parsed_data.values.map { |airport_data| airport_data["icao"] }
end

def self.all
@all ||= parsed_data.values.map do |airport_data|
airport_from_parsed_data_element(airport_data)
Expand Down
7 changes: 7 additions & 0 deletions spec/airports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
it { is_expected.to include("LHR") }
end

describe ".icao_codes" do
subject { described_class.icao_codes }

it { is_expected.to be_a(Array) }
it { is_expected.to include("EGLL") }
end

describe ".all" do
subject { described_class.all }

Expand Down

0 comments on commit bd96675

Please sign in to comment.