Class: AddressGeocoder::Requester Abstract
- Inherits:
-
Object
- Object
- AddressGeocoder::Requester
- Defined in:
- lib/address_geocoder/requester.rb
Overview
Abstract base class for making requests to maps APIs
Direct Known Subclasses
Instance Attribute Summary collapse
-
#address ⇒ Hash
writeonly
The address to use in the request.
-
#api_key ⇒ Hash
writeonly
The api_key to use in the request.
-
#language ⇒ Hash
writeonly
The language to return the request in.
-
#parser ⇒ Parser
writeonly
A class instance.
-
#result ⇒ Hash
readonly
The result of a request to a maps API.
Instance Method Summary collapse
-
#array_result ⇒ Array<Hash>
abstract
A collection of possible addresses.
-
#connection_error(msg) ⇒ Object
Raise a connection error.
-
#initialize(args = {}) ⇒ Requester
constructor
A new instance of Requester.
- #make_call ⇒ void abstract
-
#success? ⇒ Boolean
abstract
True, or false if the request failed.
Constructor Details
#initialize(args = {}) ⇒ Requester
Returns a new instance of Requester.
23 24 25 |
# File 'lib/address_geocoder/requester.rb', line 23 def initialize(args = {}) @parser = args[:parser] end |
Instance Attribute Details
#address=(value) ⇒ Hash (writeonly)
Returns the address to use in the request.
12 13 14 |
# File 'lib/address_geocoder/requester.rb', line 12 def address=(value) @address = value end |
#api_key=(value) ⇒ Hash (writeonly)
Returns the api_key to use in the request.
18 19 20 |
# File 'lib/address_geocoder/requester.rb', line 18 def api_key=(value) @api_key = value end |
#language=(value) ⇒ Hash (writeonly)
Returns the language to return the request in.
15 16 17 |
# File 'lib/address_geocoder/requester.rb', line 15 def language=(value) @language = value end |
#parser=(value) ⇒ Parser (writeonly)
Returns a class instance.
9 10 11 |
# File 'lib/address_geocoder/requester.rb', line 9 def parser=(value) @parser = value end |
#result ⇒ Hash (readonly)
Returns the result of a request to a maps API.
21 22 23 |
# File 'lib/address_geocoder/requester.rb', line 21 def result @result end |
Instance Method Details
#array_result ⇒ Array<Hash>
Abstract base method for returning a compacted, flattened array of different address responses.
Returns a collection of possible addresses.
43 44 45 |
# File 'lib/address_geocoder/requester.rb', line 43 def array_result [@result['results']].flatten end |
#connection_error(msg) ⇒ Object
Raise a connection error
48 49 50 |
# File 'lib/address_geocoder/requester.rb', line 48 def connection_error(msg) raise ConnectionError, msg end |
#make_call ⇒ void
Abstract base method for initiating a call to a maps API
This method returns an undefined value.
29 30 31 |
# File 'lib/address_geocoder/requester.rb', line 29 def make_call raise NeedToOveride, 'make_call' end |
#success? ⇒ Boolean
Abstract base method for checking if a call to a maps API suceeded
Returns true, or false if the request failed.
36 37 38 |
# File 'lib/address_geocoder/requester.rb', line 36 def success? raise NeedToOveride, 'success?' end |