Class: JetBluePlaneTracker::Tracker

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/jetblue_plane_tracker/tracker.rb

Instance Method Summary collapse

Constructor Details

#initializeTracker

Returns a new instance of Tracker.



7
8
9
# File 'lib/jetblue_plane_tracker/tracker.rb', line 7

def initialize()

end

Instance Method Details

#flight_status(params = {}) ⇒ Object Also known as: find_flight



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jetblue_plane_tracker/tracker.rb', line 11

def flight_status(params={})
	data = get_data(params)
	flight_date = params.has_key?("date") ? options[:date] : Date.today
	flights = []
	legs = []
	data['flights'].each do |flight|
		legs = []
		flight['legs'].each do |leg|
			lg = Leg.new(leg["flightNo"], flight_date,
							Departure.parse(leg), Arrival.parse(leg), leg['flightStatus'])
			legs << lg
		end
		fl = Flight.new(flight["tripOrigin"], flight["tripDestination"], legs)
		flights << fl
	end
	flights
end