Module: StationMaster::Schedule::Find

Includes:
Ask
Included in:
StationMaster::Schedule
Defined in:
lib/station_master/schedule/find.rb

Instance Method Summary collapse

Instance Method Details

#find_station_arrivals(station_code, time = Time.now) ⇒ Object



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

def find_station_arrivals(station_code, time = Time.now)
  MultiJson::load(
    remote_call(:arrivals, {
      station_code: station_code,
      time: format_time(time.in_time_zone(TIME_ZONE)) }),
    symbolize_keys: true)
  .inject([]) do |array, arrival_hash|
    array << Arrival.new(arrival_hash)
  end
end

#find_station_departures(station_code, time = Time.now) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/station_master/schedule/find.rb', line 17

def find_station_departures(station_code, time = Time.now)
  MultiJson::load(
    remote_call(:departures, {
      station_code: station_code,
      time: format_time(time.in_time_zone(TIME_ZONE)) }),
    symbolize_keys: true)
  .inject([]) do |array, arrival_hash|
    array << Departure.new(arrival_hash)
  end
end