Class: MachO::MachOStructure Abstract
- Inherits:
-
Object
- Object
- MachO::MachOStructure
- Defined in:
- lib/macho/structure.rb
Overview
This class is abstract.
A general purpose pseudo-structure. Described in detail in docs/machostructure-dsl.md.
Direct Known Subclasses
Headers::FatArch, Headers::FatHeader, Headers::MachHeader, Headers::PrelinkedKernelHeader, LoadCommands::LoadCommand, Sections::Section
Defined Under Namespace
Modules: Fields
Class Attribute Summary collapse
-
.min_args ⇒ Object
readonly
Returns the value of attribute min_args.
Class Method Summary collapse
- .bytesize ⇒ Object
- .format ⇒ Object
-
.new_from_bin(endianness, bin) ⇒ MachO::MachOStructure
private
The resulting structure.
Instance Method Summary collapse
-
#initialize(*args) ⇒ MachOStructure
constructor
A new instance of MachOStructure.
-
#to_h ⇒ Hash
A hash representation of this MachOStructure.
Constructor Details
#initialize(*args) ⇒ MachOStructure
Returns a new instance of MachOStructure.
75 76 77 78 79 |
# File 'lib/macho/structure.rb', line 75 def initialize(*args) raise ArgumentError, "Invalid number of arguments" if args.size < self.class.min_args @values = args end |
Class Attribute Details
.min_args ⇒ Object (readonly)
Returns the value of attribute min_args.
92 93 94 |
# File 'lib/macho/structure.rb', line 92 def min_args @min_args end |
Class Method Details
.bytesize ⇒ Object
108 109 110 |
# File 'lib/macho/structure.rb', line 108 def bytesize @bytesize ||= @size_list.sum end |
.format ⇒ Object
104 105 106 |
# File 'lib/macho/structure.rb', line 104 def format @format ||= @fmt_list.join 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.
98 99 100 101 102 |
# File 'lib/macho/structure.rb', line 98 def new_from_bin(endianness, bin) format = Utils.specialize_format(self.format, endianness) new(*bin.unpack(format)) end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash representation of this MachO::MachOStructure.
82 83 84 85 86 87 88 89 |
# File 'lib/macho/structure.rb', line 82 def to_h { "structure" => { "format" => self.class.format, "bytesize" => self.class.bytesize, }, } end |