Class: CloudMade::Route
- Inherits:
-
Object
- Object
- CloudMade::Route
- Defined in:
- lib/cloudmade/routing.rb
Overview
Wrapper around raw data being returned by routing service
Constant Summary collapse
- STATUS_OK =
0
- STATUS_ERROR =
1
Instance Attribute Summary collapse
-
#geometry ⇒ Object
Geometry of route.
-
#instructions ⇒ Object
List of route instructions.
-
#status ⇒ Object
Status of response.
-
#status_message ⇒ Object
Returns the value of attribute status_message.
-
#summary ⇒ Object
Statistical info about the route.
-
#version ⇒ Object
Version of routing HTTP API.
Instance Method Summary collapse
-
#initialize(data) ⇒ Route
constructor
A new instance of Route.
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ Route
Returns a new instance of Route.
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cloudmade/routing.rb', line 91 def initialize(data) begin self.status = data['status'].to_i self.instructions = data['route_instructions'].map { |instruction_data| RouteInstruction.new(instruction_data) } self.summary = RouteSummary.new(data['route_summary']) self.geometry = Line.new(data['route_geometry']) self.version = data['version'] self. = data['status_message'] rescue raise RouteNotFound end end |
Instance Attribute Details
#geometry ⇒ Object
Geometry of route
81 82 83 |
# File 'lib/cloudmade/routing.rb', line 81 def geometry @geometry end |
#instructions ⇒ Object
List of route instructions
77 78 79 |
# File 'lib/cloudmade/routing.rb', line 77 def instructions @instructions end |
#status ⇒ Object
Status of response
85 86 87 |
# File 'lib/cloudmade/routing.rb', line 85 def status @status end |
#status_message ⇒ Object
Returns the value of attribute status_message.
86 87 88 |
# File 'lib/cloudmade/routing.rb', line 86 def @status_message end |
#summary ⇒ Object
Statistical info about the route
79 80 81 |
# File 'lib/cloudmade/routing.rb', line 79 def summary @summary end |
#version ⇒ Object
Version of routing HTTP API
83 84 85 |
# File 'lib/cloudmade/routing.rb', line 83 def version @version end |
Instance Method Details
#to_s ⇒ Object
104 105 106 |
# File 'lib/cloudmade/routing.rb', line 104 def to_s self.instructions.to_s end |