Sha256: 06196f09f26c8f8881e74433db5f2af6642228b5db9955aadb125ca0c714d470

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 Bytes

Contents

class Ip2LocationRecord 
  def self.init(database, ip_version)
    cls = Class.new(BinData::Record)
    cls.class_eval {
      endian :little
      i2l_ip_data :ip_from, :ip_version => ip_version
      database.each do |col|
        if [:latitude, :longitude].include? col.first
          i2l_float_data col.first
        elsif col.first == :country
          i2l_string_data :country_short
          i2l_string_data :country_long, :country_long => true
        else
          i2l_string_data col.first
        end
      end
      
      i2l_ip_data :ip_to, :ip_version => ip_version
    }
    cls 
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ip2location_ruby-8.0.1 lib/ip2location_ruby/ip2location_record.rb
ip2location_ruby-7.0.0 lib/ip2location_ruby/ip2location_record.rb