Class: JetBluePlaneTracker::Travel

Inherits:
Object
  • Object
show all
Defined in:
lib/jetblue_plane_tracker/travel.rb

Direct Known Subclasses

Arrival, Departure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(airport, scheduled_takeoff, actual_takeoff, terminal, gate, temperature) ⇒ Travel

Returns a new instance of Travel.



5
6
7
8
9
10
11
12
13
# File 'lib/jetblue_plane_tracker/travel.rb', line 5

def initialize(airport, scheduled_takeoff, actual_takeoff, terminal, gate, temperature)
	super()
	self.airport = Airport.find_by_iata(Airport.parse_airport_iata(airport))
	self.scheduled_takeoff = DateTime.parse(scheduled_takeoff)
	self.actual_takeoff = DateTime.parse(actual_takeoff)
	self.terminal = terminal
	self.gate = gate
	self.temperature = temperature
end

Instance Attribute Details

#actual_takeoffObject

Returns the value of attribute actual_takeoff.



3
4
5
# File 'lib/jetblue_plane_tracker/travel.rb', line 3

def actual_takeoff
  @actual_takeoff
end

#airportObject

Returns the value of attribute airport.



3
4
5
# File 'lib/jetblue_plane_tracker/travel.rb', line 3

def airport
  @airport
end

#gateObject

Returns the value of attribute gate.



3
4
5
# File 'lib/jetblue_plane_tracker/travel.rb', line 3

def gate
  @gate
end

#scheduled_takeoffObject

Returns the value of attribute scheduled_takeoff.



3
4
5
# File 'lib/jetblue_plane_tracker/travel.rb', line 3

def scheduled_takeoff
  @scheduled_takeoff
end

#temperatureObject

Returns the value of attribute temperature.



3
4
5
# File 'lib/jetblue_plane_tracker/travel.rb', line 3

def temperature
  @temperature
end

#terminalObject

Returns the value of attribute terminal.



3
4
5
# File 'lib/jetblue_plane_tracker/travel.rb', line 3

def terminal
  @terminal
end

Instance Method Details

#to_jsonObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/jetblue_plane_tracker/travel.rb', line 19

def to_json
	{
		"airport" => self.airport.to_json,
		"scheduled_takeoff" => self.scheduled_takeoff,
		"actual_takeoff" => self.actual_takeoff,
		"terminal" => self.terminal,
		"gate" => self.gate,
		"temperature" => self.temperature
	}
end

#to_sObject



15
16
17
# File 'lib/jetblue_plane_tracker/travel.rb', line 15

def to_s
	"#{type}-> Airport: #{airport.name} Scheduled Take-Off: #{scheduled_takeoff} - Actual Take-Off: #{actual_takeoff} [Terminal: #{terminal}, Gate: #{gate}, Temperature: #{temperature}]"
end

#typeObject



30
31
32
# File 'lib/jetblue_plane_tracker/travel.rb', line 30

def type
	self.class.name.sub!("JetBluePlaneTracker::", "")
end