Class: MachO::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.

Constant Summary collapse

FORMAT =
"VVa16"
SIZEOF =
24

Instance Attribute Summary collapse

Attributes inherited from LoadCommand

#cmd, #cmdsize, #offset

Instance Method Summary collapse

Methods inherited from LoadCommand

new_from_bin, #to_s, #type

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(raw_data, offset, cmd, cmdsize, uuid) ⇒ UUIDCommand

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 UUIDCommand.



219
220
221
222
# File 'lib/macho/load_commands.rb', line 219

def initialize(raw_data, offset, cmd, cmdsize, uuid)
	super(raw_data, offset, cmd, cmdsize)
	@uuid = uuid.unpack("C16") # re-unpack for the actual UUID array
end

Instance Attribute Details

#uuidArray<Fixnum> (readonly)

Returns the UUID.

Returns:

  • (Array<Fixnum>)

    the UUID



213
214
215
# File 'lib/macho/load_commands.rb', line 213

def uuid
  @uuid
end

Instance Method Details

#uuid_stringString

Returns a string representation of the UUID.

Returns:

  • (String)

    a string representation of the UUID



225
226
227
228
229
230
231
232
233
# File 'lib/macho/load_commands.rb', line 225

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

	segs.join("-")
end