class MaxMind::DB::Metadata

Metadata holds metadata about a MaxMind DB file. See maxmind.github.io/MaxMind-DB/#database-metadata for the specification.

Attributes

binary_format_major_version[R]

The major version number of the binary format used when creating the database.

@return [Integer]

binary_format_minor_version[R]

The minor version number of the binary format used when creating the database.

@return [Integer]

build_epoch[R]

The Unix epoch for the build time of the database.

@return [Integer]

database_type[R]

A string identifying the database type. e.g., “GeoIP2-City”.

@return [String]

description[R]

A hash from locales to text descriptions of the database.

@return [Hash<String, String>]

ip_version[R]

The IP version of the data in the database. A value of 4 means the database only supports IPv4. A database with a value of 6 may support both IPv4 and IPv6 lookups.

@return [Integer]

languages[R]

An array of locale codes supported by the database.

@return [Array<String>]

node_count[R]

The number of nodes in the database.

@return [Integer]

record_size[R]

The bit size of a record in the search tree.

@return [Integer]

Public Class Methods

new(map) click to toggle source

m is a hash representing the metadata map.

@!visibility private

# File lib/maxmind/db/metadata.rb, line 62
def initialize(map)
  @node_count                  = map['node_count']
  @record_size                 = map['record_size']
  @ip_version                  = map['ip_version']
  @database_type               = map['database_type']
  @languages                   = map['languages']
  @binary_format_major_version = map['binary_format_major_version']
  @binary_format_minor_version = map['binary_format_minor_version']
  @build_epoch                 = map['build_epoch']
  @description                 = map['description']
end

Public Instance Methods

node_byte_size() click to toggle source

The size of a node in bytes.

@return [Integer]

# File lib/maxmind/db/metadata.rb, line 77
def node_byte_size
  @record_size / 4
end
search_tree_size() click to toggle source

The size of the search tree in bytes.

@return [Integer]

# File lib/maxmind/db/metadata.rb, line 84
def search_tree_size
  @node_count * node_byte_size
end