Class: MachO::Headers::FatHeader

Inherits:
MachOStructure show all
Defined in:
lib/macho/headers.rb

Overview

Fat binary header structure

See Also:

  • FatArch

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.

always big-endian

"N2"
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.

8

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(magic, nfat_arch) ⇒ FatHeader

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 a new instance of FatHeader.



502
503
504
505
506
# File 'lib/macho/headers.rb', line 502

def initialize(magic, nfat_arch)
  super()
  @magic = magic
  @nfat_arch = nfat_arch
end

Instance Attribute Details

#magicInteger (readonly)

Returns the magic number of the header (and file).

Returns:

  • (Integer)

    the magic number of the header (and file)



487
488
489
# File 'lib/macho/headers.rb', line 487

def magic
  @magic
end

#nfat_archInteger (readonly)

Returns the number of fat architecture structures following the header.

Returns:

  • (Integer)

    the number of fat architecture structures following the header



490
491
492
# File 'lib/macho/headers.rb', line 490

def nfat_arch
  @nfat_arch
end

Instance Method Details

#serializeString

Returns the serialized fields of the fat header.

Returns:

  • (String)

    the serialized fields of the fat header



509
510
511
# File 'lib/macho/headers.rb', line 509

def serialize
  [magic, nfat_arch].pack(FORMAT)
end

#to_hHash

Returns a hash representation of this MachO::Headers::FatHeader.

Returns:



514
515
516
517
518
519
520
# File 'lib/macho/headers.rb', line 514

def to_h
  {
    "magic" => magic,
    "magic_sym" => MH_MAGICS[magic],
    "nfat_arch" => nfat_arch,
  }.merge super
end