Class: GeoIP::Organization

Inherits:
Object
  • Object
show all
Defined in:
ext/geoip/geoip.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*args) ⇒ Object

GeoIP::Organization.new(‘/path/to/GeoIPOrg.dat’, load_option) load_option can be:

  • :memory - load the data into memory, fastest (default)

  • :filesystem - look up from filesystem, least memory intensive

  • :index - stores in memory most recent queries



256
257
258
259
# File 'ext/geoip/geoip.c', line 256

static VALUE rb_geoip_org_new(int argc, VALUE *argv, VALUE self)
{
  return rb_geoip_database_new(mGeoIP_Organization, argc, argv, self);
}

Instance Method Details

#look_up(addr) ⇒ Object

Pass this function an IP address as a string, it will return a hash containing all the information that the database knows about the IP:

db.look_up('24.24.24.24')
=> {:name => "Road Runner"}


266
267
268
269
270
271
# File 'ext/geoip/geoip.c', line 266

VALUE rb_geoip_org_look_up(VALUE self, VALUE addr) {
  GeoIP *gi;
  Check_Type(addr, T_STRING);
  Data_Get_Struct(self, GeoIP, gi);
  return generic_single_value_lookup_response("name", GeoIP_name_by_addr(gi, StringValuePtr(addr)));
}