Class: Ipgp

Inherits:
Object
  • Object
show all
Defined in:
lib/ipgp.rb,
lib/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip, key = 'RyZBqulp7j') ⇒ Ipgp

Returns a new instance of Ipgp.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ipgp.rb', line 8

def initialize(ip, key = 'RyZBqulp7j')
  url = "http://www.ipgp.net/api/xml/#{ip}/#{key}"
  xml_data = Net::HTTP.get_response(URI.parse(url)).body
  data = XmlSimple.xml_in(xml_data)
  @region = data['Region'].first
  @city = data['City'].first
  @country = data['Country'].first
  @code = data['Code'].first
  @lng = data['Lng'].first
  @flag = data['Flag'].first
  @isp =  data['Isp'].first
  @ip = data['Ip'].first
  @lat = data['Lat'].first
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



6
7
8
# File 'lib/ipgp.rb', line 6

def city
  @city
end

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/ipgp.rb', line 6

def code
  @code
end

#countryObject (readonly)

Returns the value of attribute country.



6
7
8
# File 'lib/ipgp.rb', line 6

def country
  @country
end

#flagObject (readonly)

Returns the value of attribute flag.



6
7
8
# File 'lib/ipgp.rb', line 6

def flag
  @flag
end

#ipObject (readonly)

Returns the value of attribute ip.



6
7
8
# File 'lib/ipgp.rb', line 6

def ip
  @ip
end

#ispObject (readonly)

Returns the value of attribute isp.



6
7
8
# File 'lib/ipgp.rb', line 6

def isp
  @isp
end

#latObject (readonly)

Returns the value of attribute lat.



6
7
8
# File 'lib/ipgp.rb', line 6

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng.



6
7
8
# File 'lib/ipgp.rb', line 6

def lng
  @lng
end

#regionObject (readonly)

Returns the value of attribute region.



6
7
8
# File 'lib/ipgp.rb', line 6

def region
  @region
end