Method: GeoIP#initialize
- Defined in:
- lib/geoip.rb
#initialize(filename, options = {}) ⇒ GeoIP
Open the GeoIP database and determine the file format version.
filename is a String holding the path to the GeoIP.dat file options is a Hash allowing you to specify the caching options
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/geoip.rb', line 225 def initialize(filename, = {}) if [:preload] || !IO.respond_to?(:pread) @mutex = Mutex.new end @use_pread = IO.respond_to?(:pread) && ![:preload] = @database_type = Edition::COUNTRY @record_length = STANDARD_RECORD_LENGTH @file = File.open(filename, 'rb') detect_database_type! preload_data if [:preload] end |