Sha256: 724a535f9291a37f38ae8ddd43562de5bad308a5214521d87ac545d508adbb51

Contents?: true

Size: 692 Bytes

Versions: 7

Compression:

Stored size: 692 Bytes

Contents

module Ratis

  class Route

    attr_accessor :short_name, :directions

    def self.all
      response = Request.get 'Allroutes'
      return [] unless response.success?

      routes = response.to_hash[:allroutes_response][:routes].split(/\n/)
      atis_routes = routes.map do |r|
        r.strip!
        next if r.blank?
        r = r.split(/, /)
        Route.new r[0].strip, r[1..-1].map(&:strip)
      end
      atis_routes.compact
    end

    def initialize(short_name, directions)
      self.short_name = short_name
      self.directions = directions
    end

    def timetable(conditions)
      Timetable.where conditions.merge :route_short_name => short_name
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

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