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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ Metadata

m is a hash representing the metadata map.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/maxmind/db/metadata.rb', line 40

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

Instance Attribute Details

#binary_format_major_versionObject (readonly)

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



27
28
29
# File 'lib/maxmind/db/metadata.rb', line 27

def binary_format_major_version
  @binary_format_major_version
end

#binary_format_minor_versionObject (readonly)

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



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

def binary_format_minor_version
  @binary_format_minor_version
end

#build_epochObject (readonly)

The Unix epoch for the build time of the database.



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

def build_epoch
  @build_epoch
end

#database_typeObject (readonly)

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



20
21
22
# File 'lib/maxmind/db/metadata.rb', line 20

def database_type
  @database_type
end

#descriptionObject (readonly)

A hash from locales to text descriptions of the database.



37
38
39
# File 'lib/maxmind/db/metadata.rb', line 37

def description
  @description
end

#ip_versionObject (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.



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

def ip_version
  @ip_version
end

#languagesObject (readonly)

An array of locale codes supported by the database.



23
24
25
# File 'lib/maxmind/db/metadata.rb', line 23

def languages
  @languages
end

#node_countObject (readonly)

The number of nodes in the database.



9
10
11
# File 'lib/maxmind/db/metadata.rb', line 9

def node_count
  @node_count
end

#record_sizeObject (readonly)

The bit size of a record in the search tree.



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

def record_size
  @record_size
end

Instance Method Details

#node_byte_sizeObject

The size of a node in bytes.



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

def node_byte_size
  @record_size / 4
end

#search_tree_sizeObject

The size of the search tree in bytes.



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

def search_tree_size
  @node_count * node_byte_size
end