Class: MachO::LoadCommands::SourceVersionCommand

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

Overview

A load command specifying the version of the sources used to build the binary. Corresponds to LC_SOURCE_VERSION.

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.

"L=2Q=1".freeze
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.

16

Instance Attribute Summary collapse

Attributes inherited from LoadCommand

#cmd, #cmdsize, #view

Instance Method Summary collapse

Methods inherited from LoadCommand

create, new_from_bin, #offset, #serializable?, #serialize, #to_s, #type

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(view, cmd, cmdsize, version) ⇒ SourceVersionCommand

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



1337
1338
1339
1340
# File 'lib/macho/load_commands.rb', line 1337

def initialize(view, cmd, cmdsize, version)
  super(view, cmd, cmdsize)
  @version = version
end

Instance Attribute Details

#versionInteger (readonly)

Returns the version packed as a24.b10.c10.d10.e10.

Returns:

  • (Integer)

    the version packed as a24.b10.c10.d10.e10



1326
1327
1328
# File 'lib/macho/load_commands.rb', line 1326

def version
  @version
end

Instance Method Details

#version_stringString

A string representation of the sources used to build the binary.

Returns:

  • (String)

    a string representation of the version



1344
1345
1346
1347
1348
1349
1350
1351
1352
# File 'lib/macho/load_commands.rb', line 1344

def version_string
  binary = "%064b" % version
  segs = [
    binary[0..23], binary[24..33], binary[34..43], binary[44..53],
    binary[54..63]
  ].map { |s| s.to_i(2) }

  segs.join(".")
end