Class: Cabriolet::Models::HLPFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/models/hlp_file.rb

Overview

HLP internal file model

Represents a file within an HLP archive. HLP files contain an internal file system where each file can be compressed using LZSS MODE_MSHELP.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename: nil, offset: 0, length: 0, compressed_length: 0, compressed: true) ⇒ HLPFile

Initialize HLP file

Parameters:

  • filename (String) (defaults to: nil)

    File name within the HLP archive

  • offset (Integer) (defaults to: 0)

    Offset in the HLP archive

  • length (Integer) (defaults to: 0)

    Uncompressed file length

  • compressed_length (Integer) (defaults to: 0)

    Compressed file length

  • compressed (Boolean) (defaults to: true)

    Whether the file is compressed



20
21
22
23
24
25
26
27
28
# File 'lib/cabriolet/models/hlp_file.rb', line 20

def initialize(filename: nil, offset: 0, length: 0,
               compressed_length: 0, compressed: true)
  @filename = filename
  @offset = offset
  @length = length
  @compressed_length = compressed_length
  @compressed = compressed
  @data = nil
end

Instance Attribute Details

#compressedObject

Returns the value of attribute compressed.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def compressed
  @compressed
end

#compressed_lengthObject

Returns the value of attribute compressed_length.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def compressed_length
  @compressed_length
end

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def data
  @data
end

#filenameObject

Returns the value of attribute filename.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def filename
  @filename
end

#lengthObject

Returns the value of attribute length.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def length
  @length
end

#offsetObject

Returns the value of attribute offset.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def offset
  @offset
end

Instance Method Details

#compressed?Boolean

Check if file is compressed

Returns:

  • (Boolean)

    true if file is compressed



33
34
35
# File 'lib/cabriolet/models/hlp_file.rb', line 33

def compressed?
  @compressed
end

#read_sizeInteger

Get the size to read from archive

Returns:

  • (Integer)

    Size to read (compressed or uncompressed)



40
41
42
# File 'lib/cabriolet/models/hlp_file.rb', line 40

def read_size
  compressed? ? @compressed_length : @length
end