Class: GeoipTs::Obj

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, response) ⇒ Obj

Returns a new instance of Obj.



16
17
18
19
20
# File 'lib/geoip_ts.rb', line 16

def initialize(domain, response)
  @domain = domain
  @response = response
  build
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#responseObject

Returns the value of attribute response.



13
14
15
# File 'lib/geoip_ts.rb', line 13

def response
  @response
end

#urlObject

Returns the value of attribute url.



13
14
15
# File 'lib/geoip_ts.rb', line 13

def url
  @url
end

Instance Method Details

#buildObject



22
23
24
25
26
27
# File 'lib/geoip_ts.rb', line 22

def build
  httpresp = HTTParty.get("http://www.freegeoip.net/json/#{@domain}")
  hash = httpresp.parsed_response
  @response.set(hash)
  @response
end