Class: ExpediaApi::Entities::PackageFlight
- Inherits:
-
Object
- Object
- ExpediaApi::Entities::PackageFlight
- Defined in:
- lib/expedia_api/entities/package_flight.rb
Instance Method Summary collapse
-
#extract_flightlegs ⇒ Object
extracts the json of the flight legs from the data.
-
#flight_legs ⇒ Object
returns an array of flight legs for the given flight.
-
#index ⇒ Object
returns the flight identifier for the given flight.
-
#initialize(raw_data) ⇒ PackageFlight
constructor
A new instance of PackageFlight.
Constructor Details
#initialize(raw_data) ⇒ PackageFlight
Returns a new instance of PackageFlight.
4 5 6 |
# File 'lib/expedia_api/entities/package_flight.rb', line 4 def initialize(raw_data) @raw_data = raw_data || {} end |
Instance Method Details
#extract_flightlegs ⇒ Object
extracts the json of the flight legs from the data.
21 22 23 24 25 26 27 28 |
# File 'lib/expedia_api/entities/package_flight.rb', line 21 def extract_flightlegs data = @raw_data.fetch(:FlightItinerary, {}).fetch(:FlightLeg, []) if data.is_a?(Array) data else [data] end end |
#flight_legs ⇒ Object
returns an array of flight legs for the given flight
14 15 16 17 18 |
# File 'lib/expedia_api/entities/package_flight.rb', line 14 def flight_legs extract_flightlegs.map do |leg| PackageFlightLeg.new(leg) end end |
#index ⇒ Object
returns the flight identifier for the given flight.
9 10 11 |
# File 'lib/expedia_api/entities/package_flight.rb', line 9 def index @raw_data[:FlightIndex].to_i end |