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.

Instance Method Summary collapse

Methods inherited from LoadCommand

#cmd, #cmdsize, create, new_from_bin, #offset, #serializable?, #serialize, #to_s, #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::SourceVersionCommand.

Returns:



1351
1352
1353
1354
1355
1356
# File 'lib/macho/load_commands.rb', line 1351

def to_h
  {
    "version" => version,
    "version_string" => version_string,
  }.merge super
end

#versionInteger

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

Returns:

  • (Integer)

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



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

field :version, :uint64

#version_stringString

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

Returns:

  • (String)

    a string representation of the version



1340
1341
1342
1343
1344
1345
1346
1347
1348
# File 'lib/macho/load_commands.rb', line 1340

def version_string
  binary = "%064<version>b" % { :version => 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