Class: GeoIP::Country

Inherits:
Object
  • Object
show all
Includes:
Base, Tools
Defined in:
lib/ffi-geoip/country.rb

Instance Method Summary collapse

Methods included from Base

included, #value_to_addr

Constructor Details

#initialize(*args) ⇒ Country

Returns a new instance of Country.



8
9
10
# File 'lib/ffi-geoip/country.rb', line 8

def initialize(*args)
  initialize_geoip(*args)
end

Instance Method Details

#look_up(addr) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/ffi-geoip/country.rb', line 12

def look_up(addr)
  addr = value_to_addr(addr)
  check_type(addr, String)

  fix_encoding(
    :country_code => FFIGeoIP.GeoIP_country_code_by_addr(@ptr, addr),
    :country_code3 => FFIGeoIP.GeoIP_country_code3_by_addr(@ptr, addr),
    :country_name => FFIGeoIP.GeoIP_country_name_by_addr(@ptr, addr)
  )
end