Class: EasyGeoIP::GeoData

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ GeoData

Returns a new instance of GeoData.



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

def initialize(attributes = {})
  @ip             = attributes[:ip]
  @country        = attributes[:country]
  @country_code   = attributes[:country_code]
  @city           = attributes[:city]
  @region         = attributes[:region]
  @region_code    = attributes[:region_code]
  @postal_code    = attributes[:postal_code]
  @continent_code = attributes[:continent_code]
  @latitude       = attributes[:latitude]
  @longitude      = attributes[:longitude]
  @time_zone      = attributes[:time_zone]
  @isp            = attributes[:isp]
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def city
  @city
end

#continent_codeObject (readonly)

Returns the value of attribute continent_code.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def continent_code
  @continent_code
end

#countryObject (readonly)

Returns the value of attribute country.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def country
  @country
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def country_code
  @country_code
end

#ipObject (readonly)

Returns the value of attribute ip.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def ip
  @ip
end

#ispObject (readonly)

Returns the value of attribute isp.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def isp
  @isp
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def longitude
  @longitude
end

#postal_codeObject (readonly)

Returns the value of attribute postal_code.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def postal_code
  @postal_code
end

#regionObject (readonly)

Returns the value of attribute region.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def region
  @region
end

#region_codeObject (readonly)

Returns the value of attribute region_code.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def region_code
  @region_code
end

#time_zoneObject (readonly)

Returns the value of attribute time_zone.



3
4
5
# File 'lib/easy_geoip/geo_data.rb', line 3

def time_zone
  @time_zone
end

Instance Method Details

#to_hashObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/easy_geoip/geo_data.rb', line 22

def to_hash
  {
    ip:             ip,
    country:        country,
    country_code:   country_code,
    city:           city,
    region:         region,
    region_code:    region_code,
    postal_code:    postal_code,
    continent_code: continent_code,
    latitude:       latitude,
    longitude:      longitude,
    time_zone:      time_zone,
    isp:            isp
  }
end