Class: HMap::HMapStructure Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-hmap-prebuilt/hmap_struct.rb

Overview

This class is abstract.

A general purpose pseudo-structure.

Direct Known Subclasses

HMapBucket, HMapHeader

Constant Summary collapse

FORMAT =

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.

The String#unpack format of the data structure.

Returns:

  • (String)

    the unpacking format

''
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.

The size of the data structure, in bytes.

Returns:

  • (Integer)

    the size, in bytes

0
SWAPPED =
true

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bytesizeInteger

Returns the size, in bytes, of the represented structure.

Returns:

  • (Integer)

    the size, in bytes, of the represented structure.



27
28
29
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 27

def self.bytesize
  self::SIZEOF
end

.formatObject



31
32
33
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 31

def self.format
  self::FORMAT
end

.new_from_bin(swapped, bin) ⇒ HMap::HMapStructure

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 the resulting structure.

Parameters:

  • swapped (Bool)

    the swapped of the mapfile

  • bin (String)

    the string to be unpacked into the new structure

Returns:



43
44
45
46
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 43

def self.new_from_bin(swapped, bin)
  format = Utils.specialize_format(self::FORMAT, swapped)
  new(*bin.unpack(format))
end

.swapped?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 35

def self.swapped?
  self::SWAPPED
end

Instance Method Details

#serializeObject



48
49
50
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 48

def serialize
  [].pack(format)
end

#to_hHash

Returns a hash representation of this HMap::HMapStructure.

Returns:



53
54
55
56
57
58
59
60
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 53

def to_h
  {
    'structure' => {
      'format' => self.class::FORMAT,
      'bytesize' => self.class.bytesize
    }
  }
end