Class: Omnizip::Formats::Rar::Rar5::Header
- Inherits:
-
Object
- Object
- Omnizip::Formats::Rar::Rar5::Header
- Defined in:
- lib/omnizip/formats/rar/rar5/header.rb
Overview
Base class for RAR5 headers
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_area_size ⇒ Object
readonly
Returns the value of attribute data_area_size.
-
#extra_area ⇒ Object
readonly
Returns the value of attribute extra_area.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#header_data ⇒ Object
readonly
Returns the value of attribute header_data.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(type, flags: 0, extra_area: nil, data_area_size: nil, header_data: "") ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(type, flags: 0, extra_area: nil, data_area_size: nil, header_data: "") ⇒ Header
Returns a new instance of Header.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 22 def initialize(type, flags: 0, extra_area: nil, data_area_size: nil, header_data: "") @type = type @flags = flags @flags |= FLAG_EXTRA_AREA if extra_area @flags |= FLAG_DATA_AREA if data_area_size @extra_area = extra_area @data_area_size = data_area_size @header_data = header_data end |
Instance Attribute Details
#data_area_size ⇒ Object (readonly)
Returns the value of attribute data_area_size.
20 21 22 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 20 def data_area_size @data_area_size end |
#extra_area ⇒ Object (readonly)
Returns the value of attribute extra_area.
20 21 22 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 20 def extra_area @extra_area end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
20 21 22 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 20 def flags @flags end |
#header_data ⇒ Object (readonly)
Returns the value of attribute header_data.
20 21 22 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 20 def header_data @header_data end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 20 def type @type end |
Instance Method Details
#encode ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 33 def encode # Build header without CRC header_bytes = build_header_bytes # Calculate CRC32 crc = CRC32.calculate(header_bytes.pack("C*")) # Prepend CRC (little-endian) [crc].pack("V") + header_bytes.pack("C*") end |