Class: SabreDevStudio::Flight::Shop::Flight
- Inherits:
-
Object
- Object
- SabreDevStudio::Flight::Shop::Flight
- Defined in:
- lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb
Instance Attribute Summary collapse
-
#airlines ⇒ Object
readonly
Returns the value of attribute airlines.
-
#arrival_airport ⇒ Object
readonly
Returns the value of attribute arrival_airport.
-
#arrival_time ⇒ Object
readonly
Returns the value of attribute arrival_time.
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
-
#departure_airport ⇒ Object
readonly
Returns the value of attribute departure_airport.
-
#departure_time ⇒ Object
readonly
Returns the value of attribute departure_time.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#flight_number ⇒ Object
readonly
Returns the value of attribute flight_number.
-
#stops ⇒ Object
readonly
Returns the value of attribute stops.
Instance Method Summary collapse
- #add_connecting_flight(flight) ⇒ Object
-
#initialize(flight_segment, direction, duration) ⇒ Flight
constructor
A new instance of Flight.
- #sha ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(flight_segment, direction, duration) ⇒ Flight
Returns a new instance of Flight.
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 87 def initialize(flight_segment, direction, duration) @airlines = [] @stops = [] @connections = [] @direction = direction if direction == 'connecting' @duration = flight_segment['ElapsedTime'] else @duration = duration end parse_data(flight_segment) end |
Instance Attribute Details
#airlines ⇒ Object (readonly)
Returns the value of attribute airlines.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def airlines @airlines end |
#arrival_airport ⇒ Object (readonly)
Returns the value of attribute arrival_airport.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def arrival_airport @arrival_airport end |
#arrival_time ⇒ Object (readonly)
Returns the value of attribute arrival_time.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def arrival_time @arrival_time end |
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def connections @connections end |
#departure_airport ⇒ Object (readonly)
Returns the value of attribute departure_airport.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def departure_airport @departure_airport end |
#departure_time ⇒ Object (readonly)
Returns the value of attribute departure_time.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def departure_time @departure_time end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def direction @direction end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def duration @duration end |
#flight_number ⇒ Object (readonly)
Returns the value of attribute flight_number.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def flight_number @flight_number end |
#stops ⇒ Object (readonly)
Returns the value of attribute stops.
83 84 85 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 83 def stops @stops end |
Instance Method Details
#add_connecting_flight(flight) ⇒ Object
121 122 123 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 121 def add_connecting_flight(flight) @connections << flight.sha end |
#sha ⇒ Object
100 101 102 103 104 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 100 def sha str = "#{@airlines.first}_#{@flight_number}_#{@departure_airport}_#{@departure_time}" # Digest::SHA1.hexdigest(str) str end |
#to_hash ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 106 def to_hash { uid: sha, direction: @direction, airlines: airlines.uniq, duration: minutes_to_time(duration), departureAirport: departure_airport, arrivalAirport: arrival_airport, stops: stops, connections: connections, departureTime: reformat_date_time(departure_time), arrivalTime: reformat_date_time(arrival_time) } end |