Class: MachO::LoadCommands::UUIDCommand

Inherits:
LoadCommand show all
Defined in:
lib/macho/load_commands.rb

Overview

A load command containing a single 128-bit unique random number identifying an object produced by static link editor. Corresponds to LC_UUID.

Instance Method Summary collapse

Methods inherited from LoadCommand

#cmd, #cmdsize, create, new_from_bin, #offset, #serializable?, #serialize, #type, #view

Methods inherited from MachOStructure

bytesize, format, #initialize, new_from_bin

Constructor Details

This class inherits a constructor from MachO::MachOStructure

Instance Method Details

#to_hHash

Returns a hash representation of this MachO::LoadCommands::UUIDCommand

Returns:



389
390
391
392
393
394
# File 'lib/macho/load_commands.rb', line 389

def to_h
  {
    "uuid" => uuid,
    "uuid_string" => uuid_string,
  }.merge super
end

#to_sString

Returns an alias for uuid_string.

Returns:

  • (String)

    an alias for uuid_string



384
385
386
# File 'lib/macho/load_commands.rb', line 384

def to_s
  uuid_string
end

#uuidArray<Integer>

Returns the UUID.

Returns:

  • (Array<Integer>)

    the UUID



370
# File 'lib/macho/load_commands.rb', line 370

field :uuid, :string, :size => 16, :unpack => "C16"

#uuid_stringString

Returns a string representation of the UUID.

Returns:

  • (String)

    a string representation of the UUID



373
374
375
376
377
378
379
380
381
# File 'lib/macho/load_commands.rb', line 373

def uuid_string
  hexes = uuid.map { |elem| "%02<elem>x" % { :elem => elem } }
  segs = [
    hexes[0..3].join, hexes[4..5].join, hexes[6..7].join,
    hexes[8..9].join, hexes[10..15].join
  ]

  segs.join("-")
end