class TripSpark::Client::Routes

Public Instance Methods

all()
Alias for: list
find(key)
Alias for: get
get(key) click to toggle source

Return the route whose key matches the given key

# File lib/tripspark_api/client/routes.rb, line 13
def get key
  list.find{ |route| route.key == key }
end
Also aliased as: find
list() click to toggle source

Return a list of all routes on the system.

# File lib/tripspark_api/client/routes.rb, line 6
def list
  post_request('/RouteMap/GetRoutes/').map{ |route| Route.new(route) }
end
Also aliased as: all
route_direction_pairs(*routes) click to toggle source

Return a list of pairs of route keys and direction keys. Used when requesting vehicles.

# File lib/tripspark_api/client/routes.rb, line 21
def route_direction_pairs *routes
  list.each_with_object([]) do |route, pairs|
    next unless routes.empty? or !routes.include?(route.key)
    route.patterns.each do |pattern|
      pairs << [route.key, pattern.direction.key]
    end
  end.uniq
end