Class: Google::Maps::Route
- Inherits:
-
Object
- Object
- Google::Maps::Route
- Defined in:
- lib/google_maps/route.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#options ⇒ Object
Returns the value of attribute options.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #destination_latlong ⇒ Object
-
#initialize(from, to, options = {}) ⇒ Route
constructor
A new instance of Route.
- #method_missing(method_name, *args, &block) ⇒ Object
- #origin_latlong ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(from, to, options = {}) ⇒ Route
Returns a new instance of Route.
10 11 12 13 14 15 |
# File 'lib/google_maps/route.rb', line 10 def initialize(from, to, = {}) = { language: } unless .is_a? Hash @from = from @to = to @options = { language: :en }.merge() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/google_maps/route.rb', line 17 def method_missing(method_name, *args, &block) if route.legs.first.key?(method_name) route.legs.first.send(method_name) else super end end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
8 9 10 |
# File 'lib/google_maps/route.rb', line 8 def from @from end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/google_maps/route.rb', line 8 def @options end |
#to ⇒ Object
Returns the value of attribute to.
8 9 10 |
# File 'lib/google_maps/route.rb', line 8 def to @to end |
Instance Method Details
#destination_latlong ⇒ Object
33 34 35 |
# File 'lib/google_maps/route.rb', line 33 def destination_latlong "#{end_location.lat},#{end_location.lng}" end |
#origin_latlong ⇒ Object
29 30 31 |
# File 'lib/google_maps/route.rb', line 29 def origin_latlong "#{start_location.lat},#{start_location.lng}" end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
25 26 27 |
# File 'lib/google_maps/route.rb', line 25 def respond_to_missing?(method_name, include_private = false) route.legs.first.key?(method_name) || super end |