Module: Selectors::MalaysiaAirlines
- Included in:
- MalaysiaAirlines
- Defined in:
- lib/teecket/selectors/malaysia_airlines.rb
Instance Method Summary collapse
- #arrive_at_selector(flight) ⇒ Object
- #depart_arrive_at_formatter(datetime) ⇒ Object
- #depart_at_selector(flight) ⇒ Object
- #destination_selector(flight, transit) ⇒ Object
- #fare_formatter(fare) ⇒ Object
- #fare_selector(flight) ⇒ Object
- #flight_number_selector(flight, transit) ⇒ Object
- #origin_selector(flight) ⇒ Object
Instance Method Details
#arrive_at_selector(flight) ⇒ Object
7 8 9 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 7 def arrive_at_selector(flight) depart_arrive_at_formatter(flight["arrScheduled"]) end |
#depart_arrive_at_formatter(datetime) ⇒ Object
38 39 40 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 38 def depart_arrive_at_formatter(datetime) DateTime.parse(datetime).strftime("%I:%M %p") end |
#depart_at_selector(flight) ⇒ Object
3 4 5 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 3 def depart_at_selector(flight) depart_arrive_at_formatter(flight["depScheduled"]) end |
#destination_selector(flight, transit) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 30 def destination_selector(flight, transit) if transit flight["arrivalAirport"]["code"] else flight["arrivalAirport"]["code"] end end |
#fare_formatter(fare) ⇒ Object
42 43 44 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 42 def fare_formatter(fare) sprintf("%.2f", fare) end |
#fare_selector(flight) ⇒ Object
11 12 13 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 11 def fare_selector(flight) fare_formatter(flight["fareDetails"]["totalTripFare"]) end |
#flight_number_selector(flight, transit) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 15 def flight_number_selector(flight, transit) if transit flight.map do |arr| flight_code = arr["operatingAirline"] || arr["marketingAirline"] flight_code + arr["flightNumber"] end.join(" + ") else flight["marketingAirline"] + flight["flightNumber"] end end |
#origin_selector(flight) ⇒ Object
26 27 28 |
# File 'lib/teecket/selectors/malaysia_airlines.rb', line 26 def origin_selector(flight) flight["departureAirport"]["code"] end |