Class: MachO::LoadCommands::VersionMinCommand

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

Overview

A load command containing the minimum OS version on which the binary was built to run. Corresponds to LC_VERSION_MIN_MACOSX and LC_VERSION_MIN_IPHONEOS.

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=4"
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, sdk) ⇒ VersionMinCommand

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



1319
1320
1321
1322
1323
# File 'lib/macho/load_commands.rb', line 1319

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

Instance Attribute Details

#sdkInteger (readonly)

Returns the SDK version X.Y.Z packed as x16.y8.z8.

Returns:

  • (Integer)

    the SDK version X.Y.Z packed as x16.y8.z8



1308
1309
1310
# File 'lib/macho/load_commands.rb', line 1308

def sdk
  @sdk
end

#versionInteger (readonly)

Returns the version X.Y.Z packed as x16.y8.z8.

Returns:

  • (Integer)

    the version X.Y.Z packed as x16.y8.z8



1305
1306
1307
# File 'lib/macho/load_commands.rb', line 1305

def version
  @version
end

Instance Method Details

#sdk_stringString

A string representation of the binary's SDK version.

Returns:

  • (String)

    a string representing the SDK version.



1338
1339
1340
1341
1342
1343
1344
1345
# File 'lib/macho/load_commands.rb', line 1338

def sdk_string
  binary = "%032<sdk>b" % { :sdk => sdk }
  segs = [
    binary[0..15], binary[16..23], binary[24..31]
  ].map { |s| s.to_i(2) }

  segs.join(".")
end

#to_hHash

Returns a hash representation of this MachO::LoadCommands::VersionMinCommand.

Returns:



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

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

#version_stringString

A string representation of the binary's minimum OS version.

Returns:

  • (String)

    a string representing the minimum OS version.



1327
1328
1329
1330
1331
1332
1333
1334
# File 'lib/macho/load_commands.rb', line 1327

def version_string
  binary = "%032<version>b" % { :version => version }
  segs = [
    binary[0..15], binary[16..23], binary[24..31]
  ].map { |s| s.to_i(2) }

  segs.join(".")
end