Class: Heremaps::Base
- Inherits:
-
Object
- Object
- Heremaps::Base
- Defined in:
- lib/heremaps/resources/base.rb
Direct Known Subclasses
Geocoder::Geocode, Geocoder::Landmark, Geocoder::MultiReverse, Geocoder::Reverse, Places::Base, Routing::Calculate, Routing::CalculateIsoline, Routing::CalculateMatrix, Routing::GetRoute, Routing::GetRouteZones
Instance Attribute Summary collapse
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#service ⇒ Object
Returns the value of attribute service.
Class Method Summary collapse
Instance Method Summary collapse
- #get(options = {}) ⇒ Object
- #prepare_the_request(options = {}) ⇒ Object
- #request_url(format: "json") ⇒ Object
-
#response_to_missing?(method_sym, *arg, &block) ⇒ Boolean
direct call to instance methods as class methods.
Instance Attribute Details
#method_name ⇒ Object
Returns the value of attribute method_name.
3 4 5 |
# File 'lib/heremaps/resources/base.rb', line 3 def method_name @method_name end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/heremaps/resources/base.rb', line 3 def path @path end |
#service ⇒ Object
Returns the value of attribute service.
3 4 5 |
# File 'lib/heremaps/resources/base.rb', line 3 def service @service end |
Class Method Details
.get(options = {}) ⇒ Object
21 22 23 |
# File 'lib/heremaps/resources/base.rb', line 21 def self.get( = {}) new.get() end |
Instance Method Details
#get(options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/heremaps/resources/base.rb', line 11 def get( = {}) res = RestClient.get(request_url(:format => [:format]), :params => prepare_the_request()) res end |
#prepare_the_request(options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/heremaps/resources/base.rb', line 16 def prepare_the_request( = {}) = .merge(:apiKey => Heremaps::API_KEY) end |
#request_url(format: "json") ⇒ Object
5 6 7 8 9 |
# File 'lib/heremaps/resources/base.rb', line 5 def request_url(format: "json") format ||= "json" url = File.join("https://", service + "." + Heremaps::DOMAIN, path, "#{method_name}.#{format}") url end |
#response_to_missing?(method_sym, *arg, &block) ⇒ Boolean
direct call to instance methods as class methods.
26 27 28 29 30 31 32 |
# File 'lib/heremaps/resources/base.rb', line 26 def response_to_missing?(method_sym, *arg, &block) if instance_methods.include?(method_sym) new.send(method_sym, *arg, &block) else super end end |