Class: MachO::MachOStructure Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/macho/structure.rb

Overview

This class is abstract.

A general purpose pseudo-structure.

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

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.



18
19
20
# File 'lib/macho/structure.rb', line 18

def self.bytesize
  self::SIZEOF
end

.new_from_bin(endianness, bin) ⇒ MachO::MachOStructure

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:

  • endianness (Symbol)

    either :big or :little

  • bin (String)

    the string to be unpacked into the new structure

Returns:



26
27
28
29
30
# File 'lib/macho/structure.rb', line 26

def self.new_from_bin(endianness, bin)
  format = Utils.specialize_format(self::FORMAT, endianness)

  new(*bin.unpack(format))
end

Instance Method Details

#to_hHash

Returns a hash representation of this MachO::MachOStructure.

Returns:



33
34
35
36
37
38
39
40
# File 'lib/macho/structure.rb', line 33

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