Class: Geoplugin::Locate

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Locate

Returns a new instance of Locate.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/geoplugin/locate.rb', line 29

def initialize(attributes)
  @request = attributes['geoplugin_request']
  @status = attributes['geoplugin_status']
  @city = attributes['geoplugin_city']
  @region = attributes['geoplugin_region']
  @areacode = attributes['geoplugin_areaCode']
  @dmacode = attributes['geoplugin_dmaCode']
  @countrycode = attributes['geoplugin_countryCode']
  @countryname = attributes['geoplugin_countryName']
  @continentcode = attributes['geoplugin_continentCode']
  @latitude = attributes['geoplugin_latitude']
  @longitude = attributes['geoplugin_longitude']
  @regioncode = attributes['geoplugin_regionCode']
  @regionname = attributes['geoplugin_regionName']
  @currencycode = attributes['geoplugin_currencyCode']
  @currencysymbol = attributes['geoplugin_currencySymbol']
  @currencysymbol_utf = attributes['geoplugin_currencySymbol_UTF8']
  @currencyconverter = attributes['geoplugin_currencyConverter']
end

Instance Attribute Details

#areacodeObject (readonly)

Returns the value of attribute areacode.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def areacode
  @areacode
end

#cityObject (readonly)

Returns the value of attribute city.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def city
  @city
end

#continentcodeObject (readonly)

Returns the value of attribute continentcode.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def continentcode
  @continentcode
end

#countrycodeObject (readonly)

Returns the value of attribute countrycode.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def countrycode
  @countrycode
end

#countrynameObject (readonly)

Returns the value of attribute countryname.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def countryname
  @countryname
end

#currencycodeObject (readonly)

Returns the value of attribute currencycode.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def currencycode
  @currencycode
end

#currencyconverterObject (readonly)

Returns the value of attribute currencyconverter.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def currencyconverter
  @currencyconverter
end

#currencysymbolObject (readonly)

Returns the value of attribute currencysymbol.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def currencysymbol
  @currencysymbol
end

#currencysymbol_utfObject (readonly)

Returns the value of attribute currencysymbol_utf.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def currencysymbol_utf
  @currencysymbol_utf
end

#dmacodeObject (readonly)

Returns the value of attribute dmacode.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def dmacode
  @dmacode
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def longitude
  @longitude
end

#regionObject (readonly)

Returns the value of attribute region.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def region
  @region
end

#regioncodeObject (readonly)

Returns the value of attribute regioncode.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def regioncode
  @regioncode
end

#regionnameObject (readonly)

Returns the value of attribute regionname.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def regionname
  @regionname
end

#requestObject (readonly)

Returns the value of attribute request.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def request
  @request
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/geoplugin/locate.rb', line 11

def status
  @status
end

Class Method Details

.locate(ip = nil, options) ⇒ Object

locate



50
51
52
53
# File 'lib/geoplugin/locate.rb', line 50

def self.locate(ip = nil, options)
  response = apiresponse(ip, options)
  new(response) unless response.empty?
end