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:



412
413
414
415
416
417
# File 'lib/macho/load_commands.rb', line 412

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



407
408
409
# File 'lib/macho/load_commands.rb', line 407

def to_s
  uuid_string
end

#uuidArray<Integer>

Returns the UUID.

Returns:

  • (Array<Integer>)

    the UUID



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

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

#uuid_stringString

Returns a string representation of the UUID.

Returns:

  • (String)

    a string representation of the UUID



396
397
398
399
400
401
402
403
404
# File 'lib/macho/load_commands.rb', line 396

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