Class: ZipFinder::Client
- Inherits:
-
Object
- Object
- ZipFinder::Client
- Extended by:
- Forwardable
- Defined in:
- lib/zipfinder/client.rb
Instance Attribute Summary collapse
-
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
-
#response_handler ⇒ Object
Returns the value of attribute response_handler.
Class Method Summary collapse
Instance Method Summary collapse
- #get(zipcode) ⇒ Object
-
#initialize(http_adapter = RestClientAdapter, response_handler = ResponseHandler.new) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(http_adapter = RestClientAdapter, response_handler = ResponseHandler.new) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/zipfinder/client.rb', line 10 def initialize(http_adapter = RestClientAdapter, response_handler = ResponseHandler.new) @http_adapter = http_adapter @response_handler = response_handler end |
Instance Attribute Details
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
4 5 6 |
# File 'lib/zipfinder/client.rb', line 4 def http_adapter @http_adapter end |
#response_handler ⇒ Object
Returns the value of attribute response_handler.
4 5 6 |
# File 'lib/zipfinder/client.rb', line 4 def response_handler @response_handler end |
Class Method Details
Instance Method Details
#get(zipcode) ⇒ Object
15 16 17 18 19 |
# File 'lib/zipfinder/client.rb', line 15 def get(zipcode) url = build_url(zipcode) response = http_adapter.http_get(url) response_handler.process(response) end |