Sha256: 2db18f5428bc04c0bcc1478136d9334512ac2c79e4eed85dcea672f187c2e64e

Contents?: true

Size: 803 Bytes

Versions: 20

Compression:

Stored size: 803 Bytes

Contents

module Ratis
  class Routes
    def self.all
      response = Request.get 'Allroutes2'

      return [] unless response.success?

      # {:hexcolor=>"0", :route=>"0", :operator=>"AP", :description=>"0 - route", :publicroute=>"0", :hasrealtime=>"Y", :direction=>"*", :operatorname=>"VEOLIA-PHOENIX", :color=>"#000000"}
      routes = {}
      response.to_hash[:allroutes2_response][:routes][:item].each do |item|
        if routes.has_key? item[:route]
          routes[item[:route]] << item
        else
          routes[item[:route]] = [item]
        end
      end

      routes.map do |short_name, _routes|
        directions = _routes.map{|rte| rte[:direction] }.reject{|dir| dir == '*' }
        Route.new(short_name, directions)
      end.compact.sort_by{|rte| rte.short_name }
    end
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ratis-3.6.6 lib/ratis/routes.rb
ratis-3.6.5 lib/ratis/routes.rb
ratis-3.6.4 lib/ratis/routes.rb
ratis-3.6.3 lib/ratis/routes.rb
ratis-3.6.2 lib/ratis/routes.rb
ratis-3.6.1 lib/ratis/routes.rb
ratis-3.6.0 lib/ratis/routes.rb
ratis-3.5.0 lib/ratis/routes.rb
ratis-3.4.3 lib/ratis/routes.rb
ratis-3.4.2 lib/ratis/routes.rb
ratis-3.4.1 lib/ratis/routes.rb
ratis-3.4.0 lib/ratis/routes.rb
ratis-3.3.7 lib/ratis/routes.rb
ratis-3.3.6 lib/ratis/routes.rb
ratis-3.3.5 lib/ratis/routes.rb
ratis-3.3.4 lib/ratis/routes.rb
ratis-3.3.3 lib/ratis/routes.rb
ratis-3.3.2 lib/ratis/routes.rb
ratis-3.3.1 lib/ratis/routes.rb
ratis-3.3.0 lib/ratis/routes.rb