class GeoIP::Record

Constants

HASH_KEYS

Public Instance Methods

to_h() click to toggle source
# File lib/ffi-geoip/record.rb, line 40
def to_h
  hash = HASH_KEYS.each_with_object({}) do |key, memo|
    memo[key] = self[key] unless self[key].nil?
  end

  if self[:region]
    hash[:region_name] = FFIGeoIP.GeoIP_region_name_by_code(self[:country_code], self[:region])
  end

  fix_encoding(hash)
end