Class: MassHighways::Pair
- Inherits:
-
Object
- Object
- MassHighways::Pair
- Defined in:
- lib/mass_highways/pair.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#freeflow ⇒ Object
Returns the value of attribute freeflow.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#pair_id ⇒ Object
Returns the value of attribute pair_id.
-
#route ⇒ Object
Returns the value of attribute route.
-
#speed ⇒ Object
Returns the value of attribute speed.
-
#stale ⇒ Object
Returns the value of attribute stale.
-
#status ⇒ Object
Returns the value of attribute status.
-
#title ⇒ Object
Returns the value of attribute title.
-
#travel_time ⇒ Object
Returns the value of attribute travel_time.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Pair
constructor
A new instance of Pair.
Constructor Details
#initialize ⇒ Pair
Returns a new instance of Pair.
6 7 8 |
# File 'lib/mass_highways/pair.rb', line 6 def initialize @route = [] end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def destination @destination end |
#direction ⇒ Object
Returns the value of attribute direction.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def direction @direction end |
#freeflow ⇒ Object
Returns the value of attribute freeflow.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def freeflow @freeflow end |
#origin ⇒ Object
Returns the value of attribute origin.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def origin @origin end |
#pair_id ⇒ Object
Returns the value of attribute pair_id.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def pair_id @pair_id end |
#route ⇒ Object
Returns the value of attribute route.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def route @route end |
#speed ⇒ Object
Returns the value of attribute speed.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def speed @speed end |
#stale ⇒ Object
Returns the value of attribute stale.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def stale @stale end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def status @status end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/mass_highways/pair.rb', line 3 def title @title end |
#travel_time ⇒ Object
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 |