Class: GeoIP::Domain
- Inherits:
-
Object
- Object
- GeoIP::Domain
- Defined in:
- ext/geoip/geoip.c
Class Method Summary collapse
-
.new(*args) ⇒ Object
GeoIP::Domain.new(‘/path/to/GeoIPDomain.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.
Instance Method Summary collapse
-
#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’) => => “rr.com”.
Class Method Details
.new(*args) ⇒ Object
GeoIP::Domain.new(‘/path/to/GeoIPDomain.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
334 335 336 337 |
# File 'ext/geoip/geoip.c', line 334
static VALUE rb_geoip_domain_new(int argc, VALUE *argv, VALUE self)
{
return rb_geoip_database_new(mGeoIP_Domain, 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')
=> {:domain => "rr.com"}
344 345 346 347 348 349 |
# File 'ext/geoip/geoip.c', line 344
VALUE rb_geoip_domain_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("domain", GeoIP_name_by_addr(gi, StringValuePtr(addr)));
}
|