Class: Ipgp
- Inherits:
-
Object
- Object
- Ipgp
- Defined in:
- lib/ipgp.rb,
lib/version.rb
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#flag ⇒ Object
readonly
Returns the value of attribute flag.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#isp ⇒ Object
readonly
Returns the value of attribute isp.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
-
#initialize(ip, key = 'RyZBqulp7j') ⇒ Ipgp
constructor
A new instance of Ipgp.
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
#city ⇒ Object (readonly)
Returns the value of attribute city.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def city @city end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def code @code end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def country @country end |
#flag ⇒ Object (readonly)
Returns the value of attribute flag.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def flag @flag end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def ip @ip end |
#isp ⇒ Object (readonly)
Returns the value of attribute isp.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def isp @isp end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def lng @lng end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
6 7 8 |
# File 'lib/ipgp.rb', line 6 def region @region end |