Class: ServerSideGoogleMaps::Route
- Inherits:
-
Object
- Object
- ServerSideGoogleMaps::Route
- Defined in:
- lib/server-side-google-maps/route.rb
Instance Method Summary collapse
- #destination_address ⇒ Object
- #destination_input ⇒ Object
- #destination_point ⇒ Object
- #distance ⇒ Object
-
#initialize(points, params = {}) ⇒ Route
constructor
A new instance of Route.
- #origin_address ⇒ Object
- #origin_input ⇒ Object
- #origin_point ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(points, params = {}) ⇒ Route
Returns a new instance of Route.
3 4 5 6 7 8 9 |
# File 'lib/server-side-google-maps/route.rb', line 3 def initialize(points, params = {}) raise ArgumentError if points.length < 2 @directionses = points[0..-2].zip(points[1..-1]).map do |origin, destination| Directions.new(origin, destination, params) end end |
Instance Method Details
#destination_address ⇒ Object
23 24 25 |
# File 'lib/server-side-google-maps/route.rb', line 23 def destination_address @directionses.last.destination_address end |
#destination_input ⇒ Object
15 16 17 |
# File 'lib/server-side-google-maps/route.rb', line 15 def destination_input @directionses.last.destination_input end |
#destination_point ⇒ Object
31 32 33 |
# File 'lib/server-side-google-maps/route.rb', line 31 def destination_point @directionses.last.destination_point end |
#distance ⇒ Object
39 40 41 |
# File 'lib/server-side-google-maps/route.rb', line 39 def distance @distance ||= @directionses.map{|d| d.distance}.inject(:+) end |
#origin_address ⇒ Object
19 20 21 |
# File 'lib/server-side-google-maps/route.rb', line 19 def origin_address @directionses.first.origin_address end |
#origin_input ⇒ Object
11 12 13 |
# File 'lib/server-side-google-maps/route.rb', line 11 def origin_input @directionses.first.origin_input end |
#origin_point ⇒ Object
27 28 29 |
# File 'lib/server-side-google-maps/route.rb', line 27 def origin_point @directionses.first.origin_point end |