Skip to content

Commit

Permalink
Merge pull request #138 from timrogers/FinnLawrence/icao-codes
Browse files Browse the repository at this point in the history
Add Class Method for ICAO Codes
  • Loading branch information
timrogers authored Nov 29, 2024
2 parents be3243e + 1398d3d commit b098370
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 b098370

Please sign in to comment.