class Metrobus::Route
Route
class - domain object representing routes for the day
Constants
- ROUTES_PATH
Path for the route endpoint
Attributes
description[RW]
providerid[RW]
route[RW]
Public Class Methods
all(connection = Metrobus.connection)
click to toggle source
Returns all valid routes for the day @return [array] of Metrobus::Route
objects
# File lib/metrobus/route.rb, line 28 def self.all(connection = Metrobus.connection) routes = connection.request(ROUTES_PATH) routes.map { |hash| new(hash) } end
find(route_name, routes = all)
click to toggle source
Finds routes containing the passed in route name @param route_name [String] route_name a user is looking for @return [array] of Metrobus::Route
objects
# File lib/metrobus/route.rb, line 36 def self.find(route_name, routes = all) if routes routes.find_all { |route| route.description.downcase.include?(route_name.downcase) } end end
Public Instance Methods
directions()
click to toggle source
Gets the valid directions for this route @return [Array] valid directions for this route
# File lib/metrobus/route.rb, line 11 def directions @directions ||= Metrobus::Direction.get(@route) end
get_direction_id(direction_name)
click to toggle source
Finds directions_id containing the passed in direction_name for this route @param direction_name [String] direction_name a user is looking for @return [String] representing the diretion_id for the given route
# File lib/metrobus/route.rb, line 18 def get_direction_id(direction_name) matching_directions = directions.find do |matching_direction| matching_direction.direction_name.downcase.include?(direction_name.downcase) end matching_directions.direction_id if matching_directions end