class SeventeenMon::IPDB

Public Class Methods

instance() click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 25
def self.instance
  @instance ||= self.send :new
end

Public Instance Methods

index() click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 17
def index
  @index ||= ip_db.read(offset - 4)
end
ip_db() click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 9
def ip_db
  @ip_db ||= File.open ip_db_path, 'rb'
end
ip_db_path() click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 6
def ip_db_path
  @ip_db_path ||= File.expand_path'../../data/17monipdb.dat', __FILE__
end
max_comp_length() click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 21
def max_comp_length
  @max_comp_length ||= offset - 1028
end
offset() click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 13
def offset
  @offset ||= ip_db.read(4).unpack("Nlen")[0]
end
seek(_offset, length) click to toggle source
# File lib/seventeen_mon/ipdb.rb, line 29
def seek(_offset, length)
  IO.read(ip_db_path, length, offset + _offset - 1024).split "\t"
end