Sha256: 8bc7eda04121235fc3c8d4e17afe859316ba307f9daf047b3fff66c470ea92ba

Contents?: true

Size: 1.33 KB

Versions: 20

Compression:

Stored size: 1.33 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)

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

      direction = direction.to_s.upcase
      order     = conditions.delete(:order).to_s.upcase

      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

20 entries across 20 versions & 1 rubygems

Version Path
ratis-3.3.6 lib/ratis/route_stops.rb
ratis-3.3.5 lib/ratis/route_stops.rb
ratis-3.3.4 lib/ratis/route_stops.rb
ratis-3.3.3 lib/ratis/route_stops.rb
ratis-3.3.2 lib/ratis/route_stops.rb
ratis-3.3.1 lib/ratis/route_stops.rb
ratis-3.3.0 lib/ratis/route_stops.rb
ratis-3.2.1 lib/ratis/route_stops.rb
ratis-3.2.0 lib/ratis/route_stops.rb
ratis-3.1.8 lib/ratis/route_stops.rb
ratis-3.1.7 lib/ratis/route_stops.rb
ratis-3.1.6 lib/ratis/route_stops.rb
ratis-3.1.5.1 lib/ratis/route_stops.rb
ratis-3.1.5 lib/ratis/route_stops.rb
ratis-3.1.4 lib/ratis/route_stops.rb
ratis-3.1.3 lib/ratis/route_stops.rb
ratis-3.1.2 lib/ratis/route_stops.rb
ratis-3.1.1 lib/ratis/route_stops.rb
ratis-3.1.0 lib/ratis/route_stops.rb
ratis-3.0.0 lib/ratis/route_stops.rb