Sha256: 8a5a3d815fe43b44ba80cdd44081b768d6caabf6eb661b9f4724d467fc2d8d67

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module Ratis

  class Vehicle
    attr_accessor :route, :direction, :updatetime, :adherance, :adhchange, :vehicle_id, :offroute, :stopped, :reliable, :inservice, :speed, :heading, :route_id

    def initialize(vehicle)
      @route      = vehicle[:route]
      @direction  = vehicle[:direction]
      @updatetime = vehicle[:updatetime]
      @adherance  = vehicle[:adherance]
      @adhchange  = vehicle[:adhchange]
      @vehicle_id = vehicle[:vehicle_id]
      @offroute   = vehicle[:offroute]
      @stopped    = vehicle[:stopped]
      @reliable   = vehicle[:reliable]
      @inservice  = vehicle[:inservice]
      @speed      = vehicle[:speed]
      @heading    = vehicle[:heading]
      @route_id   = vehicle[:route_id]
    end
  end

  #--------------------------------------------

  class FleetLocation

    def self.current(conditions)
      app_id  = conditions.delete(:app_id) || 'WEB'

      response = Request.get 'Fleetlocation', {'Appid' => app_id}

      return [] unless response.success?

      response.to_array(:fleetlocation_response, :vehicles, :vehicle).map do |vehicle|
        Vehicle.new(vehicle)
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ratis-3.4.3 lib/ratis/fleet_location.rb
ratis-3.4.2 lib/ratis/fleet_location.rb