Class: NJTransit::GTFS::Queries::RoutesBetween
- Inherits:
-
Object
- Object
- NJTransit::GTFS::Queries::RoutesBetween
- Defined in:
- lib/njtransit/gtfs/queries/routes_between.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(db, from:, to:) ⇒ RoutesBetween
constructor
A new instance of RoutesBetween.
Constructor Details
#initialize(db, from:, to:) ⇒ RoutesBetween
Returns a new instance of RoutesBetween.
9 10 11 12 13 |
# File 'lib/njtransit/gtfs/queries/routes_between.rb', line 9 def initialize(db, from:, to:) @db = db @from = from @to = to end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
7 8 9 |
# File 'lib/njtransit/gtfs/queries/routes_between.rb', line 7 def db @db end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
7 8 9 |
# File 'lib/njtransit/gtfs/queries/routes_between.rb', line 7 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
7 8 9 |
# File 'lib/njtransit/gtfs/queries/routes_between.rb', line 7 def to @to end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/njtransit/gtfs/queries/routes_between.rb', line 15 def call from_stop_id = resolve_stop_id(from) to_stop_id = resolve_stop_id(to) return [] if from_stop_id.nil? || to_stop_id.nil? route_ids = find_common_route_ids(from_stop_id, to_stop_id) return [] if route_ids.empty? route_short_names(route_ids) end |