Class: Java::ComMaxmindGeoip::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/geoip-jars.rb

Constant Summary collapse

HASH_FIELDS =
{
  :country_code => :countryCode, 
  :country_name => :countryName, 
  :region_code  => :region,
  :region_name  => :region_name, 
  :city         => :city, 
  :postal_code  => :postalCode, 
  :latitude     => :latitude, 
  :longitude    => :longitude, 
  :dma_code     => :dma_code, 
  :area_code    => :area_code, 
  :metro_code   => :metro_code,
  :time_zone    => :time_zone
}

Instance Method Summary collapse

Instance Method Details

#region_nameObject



24
25
26
# File 'lib/geoip-jars.rb', line 24

def region_name
  @region_name ||= Java::ComMaxmindGeoip::regionName.region_name_by_code(countryCode, region)
end

#time_zoneObject



29
30
31
# File 'lib/geoip-jars.rb', line 29

def time_zone
  @time_zone ||= Java::ComMaxmindGeoip::timeZone.time_zone_by_country_and_region(countryCode, region)
end

#to_hObject



33
34
35
36
37
38
39
40
# File 'lib/geoip-jars.rb', line 33

def to_h
  @h ||= begin
    HASH_FIELDS.reduce({}) do |acc, (hash_field, java_field)|
      acc[hash_field] = self.send(java_field)
      acc
    end
  end
end