Class: MapQuest::Services::Directions::Response
- Defined in:
- lib/mapquest/services/directions.rb
Instance Attribute Summary
Attributes inherited from Response
Instance Method Summary collapse
-
#distance ⇒ Object
Returns the calculated distance of the route in miles.
-
#initialize(response_string, params = {}) ⇒ Response
constructor
A new instance of Response.
- #locations ⇒ Object
-
#maneuvers ⇒ Object
Returns a hash of the maneuvers in the route.
-
#narrative ⇒ Object
Returns only the narratives for the route as a list.
- #route ⇒ Object
-
#time ⇒ Object
Returns the drive time in minutes.
Methods inherited from Response
#copyright, #info, #options, #status, #valid_request?
Constructor Details
#initialize(response_string, params = {}) ⇒ Response
Returns a new instance of Response.
28 29 30 |
# File 'lib/mapquest/services/directions.rb', line 28 def initialize(response_string, params = {}) super end |
Instance Method Details
#distance ⇒ Object
Returns the calculated distance of the route in miles
42 43 44 45 46 |
# File 'lib/mapquest/services/directions.rb', line 42 def distance if valid route[:distance].to_i end end |
#locations ⇒ Object
48 49 50 51 52 |
# File 'lib/mapquest/services/directions.rb', line 48 def locations if valid route[:locations] end end |
#maneuvers ⇒ Object
Returns a hash of the maneuvers in the route
55 56 57 58 59 |
# File 'lib/mapquest/services/directions.rb', line 55 def maneuvers if valid route[:legs].first[:maneuvers] end end |
#narrative ⇒ Object
Returns only the narratives for the route as a list
62 63 64 65 66 |
# File 'lib/mapquest/services/directions.rb', line 62 def narrative if valid route[:legs].first[:maneuvers].map { |maneuver| maneuver[:narrative] } end end |
#route ⇒ Object
32 33 34 |
# File 'lib/mapquest/services/directions.rb', line 32 def route response[:route] end |
#time ⇒ Object
Returns the drive time in minutes
37 38 39 |
# File 'lib/mapquest/services/directions.rb', line 37 def time (route[:time].to_i / 60).ceil end |