Class: LookupIP::V4
- Inherits:
-
Object
- Object
- LookupIP::V4
- Defined in:
- lib/lookupip/v4.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#isp ⇒ Object
readonly
Returns the value of attribute isp.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ip, country, state, city, isp) ⇒ V4
constructor
A new instance of V4.
Constructor Details
#initialize(ip, country, state, city, isp) ⇒ V4
8 9 10 11 12 13 14 |
# File 'lib/lookupip/v4.rb', line 8 def initialize(ip, country, state, city, isp) @ip = ip @country = country @state = state @city = city @isp = isp end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
7 8 9 |
# File 'lib/lookupip/v4.rb', line 7 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
7 8 9 |
# File 'lib/lookupip/v4.rb', line 7 def country @country end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
7 8 9 |
# File 'lib/lookupip/v4.rb', line 7 def ip @ip end |
#isp ⇒ Object (readonly)
Returns the value of attribute isp.
7 8 9 |
# File 'lib/lookupip/v4.rb', line 7 def isp @isp end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/lookupip/v4.rb', line 7 def state @state end |
Class Method Details
.address(ip) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lookupip/v4.rb', line 16 def self.address(ip) @ip = ip uri = URI("https://www.iplocation.net/?query=#{@ip}&submit=IP+Lookup") page = Net::HTTP.get(uri) page = Nokogiri::HTML(page) @results = LookupIP::V4.new( @ip, page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[2]').text.strip, page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[3]').text.strip, page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[4]').text.strip, page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[2]/tr/td[1]').text.strip ) end |