Class: HMap::HMapHeader Abstract
- Inherits:
-
HMapStructure
- Object
- HMapStructure
- HMap::HMapHeader
- Defined in:
- lib/hmap/hmap/hmap_struct.rb
Overview
HMapHeader structure.
Constant Summary collapse
- FORMAT =
'L=1S=2L=4'
- SIZEOF =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
24
Constants inherited from HMapStructure
Instance Attribute Summary collapse
-
#magic ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
-
#max_value_length ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
-
#num_buckets ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
-
#num_entries ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
-
#reserved ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
-
#strings_offset ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
-
#version ⇒ HMap::HMapHeader?
readonly
The raw view associated with the load command, or nil if the HMapHeader was created via create.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length) ⇒ HMapHeader
constructor
private
A new instance of HMapHeader.
-
#serialize ⇒ String
The serialized fields of the mafile.
- #to_h ⇒ Object
Methods inherited from HMapStructure
bytesize, format, new_from_bin, swapped?
Constructor Details
#initialize(magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length) ⇒ HMapHeader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HMapHeader.
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 81 def initialize(magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length) @magic = magic @version = version @reserved = reserved @strings_offset = strings_offset @num_entries = num_entries @num_buckets = num_buckets @max_value_length = max_value_length super() end |
Instance Attribute Details
#magic ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def magic @magic end |
#max_value_length ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def max_value_length @max_value_length end |
#num_buckets ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def num_buckets @num_buckets end |
#num_entries ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def num_entries @num_entries end |
#reserved ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def reserved @reserved end |
#strings_offset ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def strings_offset @strings_offset end |
#version ⇒ HMap::HMapHeader? (readonly)
Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.
73 74 75 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 73 def version @version end |
Instance Method Details
#description ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 98 def description <<-DESC Hash bucket count: #{@num_buckets} String table entry count: #{@num_entries} Max value length: #{@max_value_length} DESC end |
#serialize ⇒ String
Returns the serialized fields of the mafile.
93 94 95 96 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 93 def serialize format = Utils.specialize_format(FORMAT, SWAPPED) [magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length].pack(format) end |
#to_h ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/hmap/hmap/hmap_struct.rb', line 106 def to_h { 'magic' => magic, 'version' => version, 'reserved' => reserved, 'strings_offset' => strings_offset, 'num_entries' => num_entries, 'num_buckets' => num_buckets, 'max_value_length' => max_value_length }.merge super end |