class CtaTrack::Stops

Attributes

result[R]
stops[R]

Public Class Methods

new(args) click to toggle source
# File lib/stops.rb, line 4
def initialize(args)
  raise ArgumentError, "must enter api key" if API.apikey.nil? 
  @result = {}
  @stops = []
  API.stops(args).root.xpath("stop").each do |node|
    @result[node.xpath('stpid').text.to_i] = {
      :stpid => node.xpath("stpid").text.to_i,
      :stpnm => node.xpath("stpnm").text,
      :lat => node.xpath("lat").text.to_i, 
      :lon => node.xpath("lon").text.to_i
    }
    @stops << node.xpath("stpnm").text
  end
end

Public Instance Methods

keys() click to toggle source
# File lib/stops.rb, line 18
def keys 
  @result.keys
end
method_missing(method_name, stop, *arguments, &block) click to toggle source
# File lib/stops.rb, line 21
def method_missing(method_name, stop, *arguments, &block)
  @result[stop][method_name.to_sym]
end
respond_to?(method_name, include_private=false) click to toggle source
# File lib/stops.rb, line 24
def respond_to?(method_name, include_private=false)
  @result[@result.keys[0]].include?("#{method_name}".to_sym)
end