Class: GeoIP::City

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

Instance Method Summary collapse

Methods included from Base

included, #value_to_addr

Constructor Details

#initialize(*args) ⇒ City

Returns a new instance of City.



8
9
10
# File 'lib/ffi-geoip/city.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
22
23
# File 'lib/ffi-geoip/city.rb', line 12

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

  record = Record.new(FFIGeoIP.GeoIP_record_by_addr(@ptr, addr))

  if !record.null?
    hash = record.to_h
    FFIGeoIP.GeoIPRecord_delete(record)
    hash
  end
end