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
# 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.points = leg.to_array(:points, :point).collect do |point|
      point.split(',').map(&:to_f)
    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



19
20
21
22
# File 'lib/ratis/itin_trace.rb', line 19

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)


24
25
26
# File 'lib/ratis/itin_trace.rb', line 24

def success?
  @success
end