class CapitalBikeshare::StationSet

Public Class Methods

new(stations = []) click to toggle source
# File lib/capital-bikeshare/station_set.rb, line 3
def initialize(stations = [])
  @stations = stations
end

Public Instance Methods

find(searchable) click to toggle source
# File lib/capital-bikeshare/station_set.rb, line 11
def find(searchable)
        case searchable
        when String
                return find_by_name(searchable)
        when Fixnum
                return find_by_id(searchable)
        end
end
find_by_id(num) click to toggle source
# File lib/capital-bikeshare/station_set.rb, line 27
def find_by_id(num)
        @stations.select{ |station| station.id == num }.first
end
find_by_name(name) click to toggle source
# File lib/capital-bikeshare/station_set.rb, line 20
def find_by_name(name)
        @stations.select do |station|
                next unless station.name
                station.name.downcase == name.downcase
        end.first
end
to_a() click to toggle source
# File lib/capital-bikeshare/station_set.rb, line 7
def to_a
  @stations.to_a
end