Class: Reroute

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

Instance Attribute Summary collapse

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) ⇒ Reroute

Returns a new instance of Reroute.



6
7
8
9
10
11
12
13
14
15
# File 'lib/reroute.rb', line 6

def initialize(json)
	@start_date = Date.strptime(json["start_date"], "%m/%d/%Y")
	@end_date = Date.strptime(json["end_date"], "%m/%d/%y")
	@message = json["message"].gsub!("\n",' ')
	@description = json["description"].gsub!("\n",' ')
	@affected_routes = Array.new
	json["affected_routes"].each do |affected_route|
		@affected_routes << Route.new(affected_route)
	end
end

Instance Attribute Details

#affected_routesObject

Returns the value of attribute affected_routes.



4
5
6
# File 'lib/reroute.rb', line 4

def affected_routes
  @affected_routes
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/reroute.rb', line 4

def description
  @description
end

#end_dateObject

Returns the value of attribute end_date.



4
5
6
# File 'lib/reroute.rb', line 4

def end_date
  @end_date
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/reroute.rb', line 4

def message
  @message
end

#start_dateObject

Returns the value of attribute start_date.



4
5
6
# File 'lib/reroute.rb', line 4

def start_date
  @start_date
end

Instance Method Details

#to_json(*a) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/reroute.rb', line 17

def to_json(*a)
	{
	'start_date' => @start_date,
	'end_date' => @end_date,
	'description' => @description,
	'affected_routes' => @affected_routes
	}.to_json(*a)
end