Sha256: de83656625f38c170863616ce4cc656e54859542e4e5a7166ce2b633c08eb322

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

module Ratis

  ################################# EXAMPLE ############################################
  #
  # Ratis::RouteStops.all :route => 8, :direction => 'S', :order => 'S'
  #
  ######################################################################################

  class RouteStops

    def self.all(conditions)
      route = conditions.delete :route
      direction = conditions.delete(:direction).to_s.upcase
      order = conditions.delete(:order).to_s.upcase

      raise ArgumentError.new('You must provide a route') unless route
      raise ArgumentError.new('You must provide a direction') unless direction

      Ratis.all_conditions_used? conditions

      request_params = {'Route' => route, 'Direction' => direction }
      request_params.merge! order ? { 'Order' => order } : {}
      response = Request.get 'Routestops', request_params

      return [] unless response.success?

      response.to_hash[:routestops_response][:stops][:stop].map do |s|
        stop = RouteStops::Stop.new
        stop.description = s[:description]
        stop.area = s[:area]
        stop.atis_stop_id = s[:atisstopid]
        stop.stop_seq = s[:stopseq]
        stop.latitude, stop.longitude = s[:point].split ','
        stop
      end
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ratis-2.5.2.8 lib/ratis/route_stops.rb
ratis-2.5.2.7 lib/ratis/route_stops.rb
ratis-2.5.2.6 lib/ratis/route_stops.rb
ratis-2.5.2.5 lib/ratis/route_stops.rb
ratis-2.5.2.4 lib/ratis/route_stops.rb
ratis-2.5.2.2 lib/ratis/route_stops.rb