Class: Cabriolet::LIT::StructureBuilder
- Inherits:
-
Object
- Object
- Cabriolet::LIT::StructureBuilder
- Defined in:
- lib/cabriolet/lit/structure_builder.rb
Overview
Builds complete LIT structure from file data
Instance Attribute Summary collapse
-
#creator_id ⇒ Object
readonly
Returns the value of attribute creator_id.
-
#io_system ⇒ Object
readonly
Returns the value of attribute io_system.
-
#language_id ⇒ Object
readonly
Returns the value of attribute language_id.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#build(file_data) ⇒ Hash
Build complete LIT structure from file data.
-
#initialize(io_system:, version: 1, language_id: 0x409, creator_id: 0) ⇒ StructureBuilder
constructor
Initialize structure builder.
Constructor Details
#initialize(io_system:, version: 1, language_id: 0x409, creator_id: 0) ⇒ StructureBuilder
Initialize structure builder
19 20 21 22 23 24 |
# File 'lib/cabriolet/lit/structure_builder.rb', line 19 def initialize(io_system:, version: 1, language_id: 0x409, creator_id: 0) @io_system = io_system @version = version @language_id = language_id @creator_id = creator_id end |
Instance Attribute Details
#creator_id ⇒ Object (readonly)
Returns the value of attribute creator_id.
11 12 13 |
# File 'lib/cabriolet/lit/structure_builder.rb', line 11 def creator_id @creator_id end |
#io_system ⇒ Object (readonly)
Returns the value of attribute io_system.
11 12 13 |
# File 'lib/cabriolet/lit/structure_builder.rb', line 11 def io_system @io_system end |
#language_id ⇒ Object (readonly)
Returns the value of attribute language_id.
11 12 13 |
# File 'lib/cabriolet/lit/structure_builder.rb', line 11 def language_id @language_id end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
11 12 13 |
# File 'lib/cabriolet/lit/structure_builder.rb', line 11 def version @version end |
Instance Method Details
#build(file_data) ⇒ Hash
Build complete LIT structure from file data
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cabriolet/lit/structure_builder.rb', line 30 def build(file_data) structure = {} # Generate GUIDs structure[:header_guid] = GuidGenerator.generate structure[:piece3_guid] = Binary::LITStructures::GUIDs::PIECE3 structure[:piece4_guid] = Binary::LITStructures::GUIDs::PIECE4 # Build directory structure[:directory] = build_directory(file_data) # Build sections structure[:sections] = build_sections # Build manifest structure[:manifest] = build_manifest(file_data) # Build secondary header metadata structure[:secondary_header] = # Calculate piece offsets and sizes structure[:pieces] = calculate_pieces(structure) # Update secondary header with content offset update_secondary_header_content_offset(structure) # Store metadata structure[:version] = @version structure[:file_data] = file_data structure end |