class HMap::HMapStructure

A general purpose pseudo-structure. @abstract

Constants

FORMAT

The String#unpack format of the data structure. @return [String] the unpacking format @api private

SIZEOF

The size of the data structure, in bytes. @return [Integer] the size, in bytes @api private

SWAPPED

Public Class Methods

bytesize() click to toggle source

@return [Integer] the size, in bytes, of the represented structure.

# File lib/cocoapods-hmap/hmap_struct.rb, line 28
def self.bytesize
  self::SIZEOF
end
format() click to toggle source
# File lib/cocoapods-hmap/hmap_struct.rb, line 32
def self.format
  self::FORMAT
end
new_from_bin(swapped, bin) click to toggle source

@param endianness [Symbol] either `:big` or `:little` @param bin [String] the string to be unpacked into the new structure @return [HMap::HMapStructure] the resulting structure @api private

# File lib/cocoapods-hmap/hmap_struct.rb, line 44
def self.new_from_bin(swapped, bin)
  format = Utils.specialize_format(self::FORMAT, swapped)
  new(*bin.unpack(format))
end
swapped?() click to toggle source
# File lib/cocoapods-hmap/hmap_struct.rb, line 36
def self.swapped?
  self::SWAPPED
end

Public Instance Methods

serialize() click to toggle source
# File lib/cocoapods-hmap/hmap_struct.rb, line 49
def serialize
  [].pack(format)
end
to_h() click to toggle source

@return [Hash] a hash representation of this {HMapStructure}.

# File lib/cocoapods-hmap/hmap_struct.rb, line 54
def to_h
  {
    'structure' => {
      'format' => self.class::FORMAT,
      'bytesize' => self.class.bytesize
    }
  }
end