Class: MassHighways::Pair

Inherits:
Object
  • Object
show all
Defined in:
lib/mass_highways/pair.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePair

Returns a new instance of Pair.



6
7
8
# File 'lib/mass_highways/pair.rb', line 6

def initialize
  @route = []
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def destination
  @destination
end

#directionObject

Returns the value of attribute direction.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def direction
  @direction
end

#freeflowObject

Returns the value of attribute freeflow.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def freeflow
  @freeflow
end

#originObject

Returns the value of attribute origin.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def origin
  @origin
end

#pair_idObject

Returns the value of attribute pair_id.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def pair_id
  @pair_id
end

#routeObject

Returns the value of attribute route.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def route
  @route
end

#speedObject

Returns the value of attribute speed.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def speed
  @speed
end

#staleObject

Returns the value of attribute stale.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def stale
  @stale
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def status
  @status
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def title
  @title
end

#travel_timeObject

Returns the value of attribute travel_time.



3
4
5
# File 'lib/mass_highways/pair.rb', line 3

def travel_time
  @travel_time
end

Class Method Details

.parse(node) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mass_highways/pair.rb', line 10

def self.parse(node)
  pair = self.new
  pair.pair_id = node.search('PairID').first.text.to_i
  pair.title = node.search('Title').first.text
  pair.direction = node.search('Direction').first.text
  pair.origin = node.search('Origin').first.text
  pair.destination = node.search('Destination').first.text
  pair.speed = node.search('Speed').first.text.to_f
  pair.travel_time = node.search('TravelTime').first.text.to_f
  pair.freeflow = node.search('FreeFlow').first.text.to_f

  node.search('Routes Route').each do |route_node|
    lat = route_node.search('lat').first.text.to_f
    lon = route_node.search('lon').first.text.to_f
    pair.route << { lat: lat, lon: lon }
  end

  pair
end