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.



125
126
127
128
129
130
# File 'lib/hmap/hmap/hmap_struct.rb', line 125

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

Instance Attribute Details

#keyObject

Returns the value of attribute key.



120
121
122
# File 'lib/hmap/hmap/hmap_struct.rb', line 120

def key
  @key
end

#perfixObject

Returns the value of attribute perfix.



120
121
122
# File 'lib/hmap/hmap/hmap_struct.rb', line 120

def perfix
  @perfix
end

#suffixObject

Returns the value of attribute suffix.



120
121
122
# File 'lib/hmap/hmap/hmap_struct.rb', line 120

def suffix
  @suffix
end

#uuidObject

Returns the value of attribute uuid.



120
121
122
# File 'lib/hmap/hmap/hmap_struct.rb', line 120

def uuid
  @uuid
end

Instance Method Details

#serializeString

Returns the serialized fields of the mafile.

Returns:

  • (String)

    the serialized fields of the mafile



133
134
135
136
# File 'lib/hmap/hmap/hmap_struct.rb', line 133

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

#to_aObject



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

def to_a
  [key, perfix, suffix]
end

#to_hObject



142
143
144
145
146
147
148
# File 'lib/hmap/hmap/hmap_struct.rb', line 142

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