Class: GeoIP::ISP

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::ISP.new(‘/path/to/GeoIPISP.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



282
283
284
285
# File 'ext/geoip/geoip.c', line 282

static VALUE rb_geoip_isp_new(int argc, VALUE *argv, VALUE self)
{
  return rb_geoip_database_new(mGeoIP_ISP, 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')
=> {:isp => "Road Runner"}


292
293
294
295
296
297
# File 'ext/geoip/geoip.c', line 292

VALUE rb_geoip_isp_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("isp", GeoIP_name_by_addr(gi, StringValuePtr(addr)));
}