Class: MaxMind::DB::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/maxmind/db/metadata.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#binary_format_major_versionInteger (readonly)

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

Returns:

  • (Integer)


41
42
43
# File 'lib/maxmind/db/metadata.rb', line 41

def binary_format_major_version
  @binary_format_major_version
end

#binary_format_minor_versionInteger (readonly)

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

Returns:

  • (Integer)


47
48
49
# File 'lib/maxmind/db/metadata.rb', line 47

def binary_format_minor_version
  @binary_format_minor_version
end

#build_epochInteger (readonly)

The Unix epoch for the build time of the database.

Returns:

  • (Integer)


52
53
54
# File 'lib/maxmind/db/metadata.rb', line 52

def build_epoch
  @build_epoch
end

#database_typeString (readonly)

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

Returns:

  • (String)


30
31
32
# File 'lib/maxmind/db/metadata.rb', line 30

def database_type
  @database_type
end

#descriptionHash<String, String> (readonly)

A hash from locales to text descriptions of the database.

Returns:

  • (Hash<String, String>)


57
58
59
# File 'lib/maxmind/db/metadata.rb', line 57

def description
  @description
end

#ip_versionInteger (readonly)

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.

Returns:

  • (Integer)


25
26
27
# File 'lib/maxmind/db/metadata.rb', line 25

def ip_version
  @ip_version
end

#languagesArray<String> (readonly)

An array of locale codes supported by the database.

Returns:

  • (Array<String>)


35
36
37
# File 'lib/maxmind/db/metadata.rb', line 35

def languages
  @languages
end

#node_countInteger (readonly)

The number of nodes in the database.

Returns:

  • (Integer)


13
14
15
# File 'lib/maxmind/db/metadata.rb', line 13

def node_count
  @node_count
end

#record_sizeInteger (readonly)

The bit size of a record in the search tree.

Returns:

  • (Integer)


18
19
20
# File 'lib/maxmind/db/metadata.rb', line 18

def record_size
  @record_size
end

Instance Method Details

#node_byte_sizeInteger

The size of a node in bytes.

Returns:

  • (Integer)


77
78
79
# File 'lib/maxmind/db/metadata.rb', line 77

def node_byte_size
  @record_size / 4
end

#search_tree_sizeInteger

The size of the search tree in bytes.

Returns:

  • (Integer)


84
85
86
# File 'lib/maxmind/db/metadata.rb', line 84

def search_tree_size
  @node_count * node_byte_size
end