Class: Geogle::Model::Route
- Inherits:
-
Object
- Object
- Geogle::Model::Route
- Defined in:
- lib/geogle/model/route.rb
Instance Method Summary collapse
-
#destination ⇒ Object
Name of destination address.
-
#distance ⇒ Object
Total distance.
-
#duration ⇒ Object
Total duration.
-
#origin ⇒ Object
Name of starting address.
-
#path ⇒ Object
Array of points that represents the entire path.
Instance Method Details
#destination ⇒ Object
Name of destination address
37 38 39 |
# File 'lib/geogle/model/route.rb', line 37 def destination legs.last.end_address end |
#distance ⇒ Object
Total distance
27 28 29 |
# File 'lib/geogle/model/route.rb', line 27 def distance sum_values(legs.map(&:distance)) end |
#duration ⇒ Object
Total duration
22 23 24 |
# File 'lib/geogle/model/route.rb', line 22 def duration sum_values(legs.map(&:duration)) end |
#origin ⇒ Object
Name of starting address
32 33 34 |
# File 'lib/geogle/model/route.rb', line 32 def origin legs.first.start_address end |
#path ⇒ Object
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 |