Class: CloudMade::Route

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.status_message = data['status_message']
  rescue
    raise RouteNotFound
  end
end

Instance Attribute Details

#geometryObject

Geometry of route



81
82
83
# File 'lib/cloudmade/routing.rb', line 81

def geometry
  @geometry
end

#instructionsObject

List of route instructions



77
78
79
# File 'lib/cloudmade/routing.rb', line 77

def instructions
  @instructions
end

#statusObject

Status of response



85
86
87
# File 'lib/cloudmade/routing.rb', line 85

def status
  @status
end

#status_messageObject

Returns the value of attribute status_message.



86
87
88
# File 'lib/cloudmade/routing.rb', line 86

def status_message
  @status_message
end

#summaryObject

Statistical info about the route



79
80
81
# File 'lib/cloudmade/routing.rb', line 79

def summary
  @summary
end

#versionObject

Version of routing HTTP API



83
84
85
# File 'lib/cloudmade/routing.rb', line 83

def version
  @version
end

Instance Method Details

#to_sObject



104
105
106
# File 'lib/cloudmade/routing.rb', line 104

def to_s
  self.instructions.to_s
end