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:



1252
1253
1254
1255
1256
1257
# File 'lib/macho/load_commands.rb', line 1252

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



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

field :version, :uint64

#version_stringString

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

Returns:

  • (String)

    a string representation of the version



1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'lib/macho/load_commands.rb', line 1241

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