Class: HMap::HMapBucket Abstract

Inherits:
HMapStructure show all
Defined in:
lib/hmap/hmap/hmap_struct.rb

Overview

This class is abstract.

HMapBucket structure.

Constant Summary collapse

SIZEOF =
12
FORMAT =
'L=3'

Constants inherited from HMapStructure

HMap::HMapStructure::SWAPPED

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HMapStructure

bytesize, format, new_from_bin, swapped?

Constructor Details

#initialize(key, perfix, suffix) ⇒ HMapBucket

Returns a new instance of HMapBucket.



128
129
130
131
132
133
# File 'lib/hmap/hmap/hmap_struct.rb', line 128

def initialize(key, perfix, suffix)
  @key = key
  @perfix = perfix
  @suffix = suffix
  super()
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



123
124
125
# File 'lib/hmap/hmap/hmap_struct.rb', line 123

def key
  @key
end

#perfixObject

Returns the value of attribute perfix.



123
124
125
# File 'lib/hmap/hmap/hmap_struct.rb', line 123

def perfix
  @perfix
end

#suffixObject

Returns the value of attribute suffix.



123
124
125
# File 'lib/hmap/hmap/hmap_struct.rb', line 123

def suffix
  @suffix
end

Instance Method Details

#serializeString

Returns the serialized fields of the mafile.

Returns:

  • (String)

    the serialized fields of the mafile



136
137
138
139
# File 'lib/hmap/hmap/hmap_struct.rb', line 136

def serialize
  format = Utils.specialize_format(FORMAT, SWAPPED)
  [key, perfix, suffix].pack(format)
end

#to_aObject



141
142
143
# File 'lib/hmap/hmap/hmap_struct.rb', line 141

def to_a
  [key, perfix, suffix]
end

#to_hObject



145
146
147
148
149
150
151
# File 'lib/hmap/hmap/hmap_struct.rb', line 145

def to_h
  {
    'key' => key,
    'perfix' => perfix,
    'suffix' => suffix
  }.merge super
end