Sha256: 9077d05581f6ce6753367f34cc9bc8c3d97910fbbcb055aaa745d239a4960027

Contents?: true

Size: 626 Bytes

Versions: 3

Compression:

Stored size: 626 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,:elevation].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

3 entries across 3 versions & 1 rubygems

Version Path
ip2location_ruby-0.3.2 lib/ip2location_ruby/ip2location_record.rb
ip2location_ruby-0.3.1 lib/ip2location_ruby/ip2location_record.rb
ip2location_ruby-0.2.0 lib/ip2location_ruby/ip2location_record.rb