Class: Lookup::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/lookup/base.rb

Direct Known Subclasses

GoogleLookup, ZiptasticLookup

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zipcode, options = {}) ⇒ Base

Returns a new instance of Base.



18
19
20
# File 'lib/lookup/base.rb', line 18

def initialize(zipcode, options = {})
  @zipcode = zipcode
end

Instance Attribute Details

#geo_objObject

Returns the value of attribute geo_obj.



8
9
10
# File 'lib/lookup/base.rb', line 8

def geo_obj
  @geo_obj
end

#responseObject

Returns the value of attribute response.



8
9
10
# File 'lib/lookup/base.rb', line 8

def response
  @response
end

#response_objObject

Returns the value of attribute response_obj.



8
9
10
# File 'lib/lookup/base.rb', line 8

def response_obj
  @response_obj
end

#zipcodeObject

Returns the value of attribute zipcode.



8
9
10
# File 'lib/lookup/base.rb', line 8

def zipcode
  @zipcode
end

Class Method Details

.process(zipcode, options = {}) ⇒ Object



10
11
12
# File 'lib/lookup/base.rb', line 10

def self.process(zipcode, options = {})
  new(zipcode, options).process
end

Instance Method Details

#api_requestObject



14
15
16
# File 'lib/lookup/base.rb', line 14

def api_request
  Net::HTTP.get(parsed_url)
end

#parsed_urlObject



22
23
24
# File 'lib/lookup/base.rb', line 22

def parsed_url
  URI.parse(search_url)
end

#processObject



26
27
28
29
30
31
# File 'lib/lookup/base.rb', line 26

def process
  begin
    self.response = api_request
  rescue
  end
end