Class: Departure

Inherits:
CUMTD show all
Defined in:
lib/departure.rb

Instance Method Summary collapse

Methods inherited from CUMTD

all_routes, all_stops, #api_key, #get_departures_by_stop, #get_reroutes, #get_routes, #get_routes_by_stop, #get_shape_between_stops, #get_shape_by_id, #get_stop_by_id, #get_stop_times_by_stop, #get_stop_times_by_trip, #get_stops, #get_stops_by_lat_lon, #get_stops_by_search, #get_trip_by_id, #get_trips_by_block, #get_vehicle_by_id, #get_vehicles, #get_vehicles_by_route_id, #nearest_departures, #print_all_departures, reroutes, #serialize_routes, #serialize_stops, #serialize_vehicles

Constructor Details

#initialize(json) ⇒ Departure

Returns a new instance of Departure.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/departure.rb', line 4

def initialize(json)
	@stop_id = json["stop_id"]
	@headsign = json["headsign"]
	@trip = Trip.new(json["trip"])
	@vehicle_id = json["vehicle_id"]
	@origin = CUMTD.all_stops.select { |stop| stop.stop_points.each == \
		json["origin"]["stop_id"] }
	@destination = CUMTD.all_stops.select { |stop| stop.stop_points.each == \
		json["destination"]["stop_id"] }
	@is_monitored = json["is_monitored"]
	@is_scheduled = json["is_scheduled"]
	@scheduled = DateTime.parse(json["scheduled"]).to_time
	@expected = DateTime.parse(json["expected"]).to_time
	@expected_mins = json["expected_mins"]
	@location = Hash[:lat, json["location"]["lat"], :lon, json["location"]["lon"]]
end

Instance Method Details

#destinationObject



41
42
43
# File 'lib/departure.rb', line 41

def destination
	@destination
end

#expectedObject



57
58
59
# File 'lib/departure.rb', line 57

def expected
	@expected
end

#expected_minsObject



61
62
63
# File 'lib/departure.rb', line 61

def expected_mins
	@expected_mins
end

#headsignObject



25
26
27
# File 'lib/departure.rb', line 25

def headsign
	@headsign
end

#is_monitoredObject



45
46
47
# File 'lib/departure.rb', line 45

def is_monitored
	@is_monitored
end

#is_scheduledObject



49
50
51
# File 'lib/departure.rb', line 49

def is_scheduled
	@is_scheduled
end

#locationObject



65
66
67
# File 'lib/departure.rb', line 65

def location
	@location
end

#originObject



37
38
39
# File 'lib/departure.rb', line 37

def origin
	@origin
end

#scheduledObject



53
54
55
# File 'lib/departure.rb', line 53

def scheduled
	@scheduled
end

#stop_idObject



21
22
23
# File 'lib/departure.rb', line 21

def stop_id
	@stop_id
end

#tripObject



29
30
31
# File 'lib/departure.rb', line 29

def trip
	@trip
end

#vehicle_idObject



33
34
35
# File 'lib/departure.rb', line 33

def vehicle_id
	@vehicle_id
end