Class: GoTransit::Schedule
- Inherits:
-
ApiResource
- Object
- ApiResource
- GoTransit::Schedule
- Defined in:
- lib/go_transit/resources/schedule.rb
Defined Under Namespace
Classes: AllLines, Journey, Line, Trip
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#trips ⇒ Object
Returns the value of attribute trips.
Class Method Summary collapse
- .journey(date:, from_stop_code:, to_stop_code:, start_time:, max_journey:) ⇒ Object
- .line(date:, line_code:, line_direction:) ⇒ Object
- .trip(date:, trip_number:) ⇒ Object
Methods inherited from ApiResource
Constructor Details
This class inherits a constructor from GoTransit::ApiResource
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
3 4 5 |
# File 'lib/go_transit/resources/schedule.rb', line 3 def lines @lines end |
#trips ⇒ Object
Returns the value of attribute trips.
3 4 5 |
# File 'lib/go_transit/resources/schedule.rb', line 3 def trips @trips end |
Class Method Details
.journey(date:, from_stop_code:, to_stop_code:, start_time:, max_journey:) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/go_transit/resources/schedule.rb', line 5 def self.journey(date:, from_stop_code:, to_stop_code:, start_time:, max_journey:) formatted_date = date.strftime("%Y%m%d") client = Client.new response = client.get( "Schedule/Journey/#{formatted_date}/#{from_stop_code}/" + "#{to_stop_code}/#{start_time}/#{max_journey}" ) Schedule::Journey.new(response.data) end |
.line(date:, line_code:, line_direction:) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/go_transit/resources/schedule.rb', line 16 def self.line(date:, line_code:, line_direction:) formatted_date = date.strftime("%Y%m%d") client = Client.new response = client.get( "Schedule/Line/#{formatted_date}/#{line_code}/#{line_direction}" ) new(response.data).lines end |
.trip(date:, trip_number:) ⇒ Object
25 26 27 28 29 |
# File 'lib/go_transit/resources/schedule.rb', line 25 def self.trip(date:, trip_number:) client = Client.new response = client.get("Schedule/Trip/#{date}/#{trip_number}") new(response.data).trips end |