Class: Geogle::Model::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/geogle/model/route.rb

Instance Method Summary collapse

Instance Method Details

#destinationObject

Name of destination address



37
38
39
# File 'lib/geogle/model/route.rb', line 37

def destination
  legs.last.end_address
end

#distanceObject

Total distance



27
28
29
# File 'lib/geogle/model/route.rb', line 27

def distance
  sum_values(legs.map(&:distance))
end

#durationObject

Total duration



22
23
24
# File 'lib/geogle/model/route.rb', line 22

def duration
  sum_values(legs.map(&:duration))
end

#originObject

Name of starting address



32
33
34
# File 'lib/geogle/model/route.rb', line 32

def origin
  legs.first.start_address
end

#pathObject

Array of points that represents the entire path



42
43
44
45
46
# File 'lib/geogle/model/route.rb', line 42

def path
  coordinates = legs.map(&:steps).flatten.map(&:start_location)
  coordinates << legs.last.steps.last.end_location
  coordinates
end