Class: Ratis::ItinTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/ratis/itin_trace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ItinTrace

Returns a new instance of ItinTrace.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ratis/itin_trace.rb', line 7

def initialize(response)
  @success     = response.success?
  @map_extents = response.body[:itintrace_response][:mapextents].split(',').map(&:to_f).each_slice(2).to_a
  @legs        = response.body.to_array(:itintrace_response, :legs, :leg).map { |l| Hashie::Mash.new l }

  @legs.each do |leg|
    leg.distance = leg.distance.to_f

    leg.points = leg.to_array(:points, :point).collect do |point|
      point.split(',').map(&:to_f)
    end

    leg.stops = leg.to_array(:stops, :stop).collect do |stop|
      stop.point = stop.point.split(',').map(&:to_f)
      stop
    end
  end
end

Instance Attribute Details

#legsObject

Returns the value of attribute legs.



5
6
7
# File 'lib/ratis/itin_trace.rb', line 5

def legs
  @legs
end

#map_extentsObject

Returns the value of attribute map_extents.



5
6
7
# File 'lib/ratis/itin_trace.rb', line 5

def map_extents
  @map_extents
end

#successObject

Returns the value of attribute success.



5
6
7
# File 'lib/ratis/itin_trace.rb', line 5

def success
  @success
end

Class Method Details

.for_tid(tid, trace_info) ⇒ Object



26
27
28
29
# File 'lib/ratis/itin_trace.rb', line 26

def self.for_tid(tid, trace_info)
  response = Request.get 'Itintrace', {'Tid' => tid, 'Traceinfo' => trace_info}
  ItinTrace.new(response)
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ratis/itin_trace.rb', line 31

def success?
  @success
end