Class: Omnizip::Formats::Iso::RockRidge::SUEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/formats/iso/rock_ridge.rb

Overview

System Use Entry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signature, version: 1, data: "") ⇒ SUEntry

Initialize entry

Parameters:

  • signature (String)

    2-byte signature

  • version (Integer) (defaults to: 1)

    Entry version

  • data (String) (defaults to: "")

    Entry data



38
39
40
41
42
43
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 38

def initialize(signature, version: 1, data: "")
  @signature = signature
  @length = 4 + data.bytesize
  @version = version
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



31
32
33
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 31

def data
  @data
end

#lengthObject

Returns the value of attribute length.



31
32
33
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 31

def length
  @length
end

#signatureObject

Returns the value of attribute signature.



31
32
33
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 31

def signature
  @signature
end

#versionObject

Returns the value of attribute version.



31
32
33
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 31

def version
  @version
end

Class Method Details

.parse(data, offset = 0) ⇒ SUEntry

Parse from binary

Parameters:

  • data (String)

    Binary data

  • offset (Integer) (defaults to: 0)

    Starting offset

Returns:



62
63
64
65
66
67
68
69
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 62

def self.parse(data, offset = 0)
  signature = data[offset, 2]
  length = data.getbyte(offset + 2)
  version = data.getbyte(offset + 3)
  entry_data = data[offset + 4, length - 4]

  new(signature, version: version, data: entry_data)
end

Instance Method Details

#to_binaryString

Convert to binary

Returns:

  • (String)

    Binary representation



48
49
50
51
52
53
54
55
# File 'lib/omnizip/formats/iso/rock_ridge.rb', line 48

def to_binary
  result = +""
  result << @signature # 2 bytes
  result << [@length].pack("C")  # 1 byte
  result << [@version].pack("C") # 1 byte
  result << @data
  result
end