Class: Cabriolet::HLP::Compressor

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/hlp/compressor.rb

Overview

Main compressor for HLP files

Creates HLP files in either QuickHelp or Windows Help format. By default, uses QuickHelp format for compatibility.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io_system = nil) ⇒ Compressor

Initialize compressor

Parameters:

  • io_system (System::IOSystem, nil) (defaults to: nil)

    Custom I/O system or nil for default



18
19
20
21
# File 'lib/cabriolet/hlp/compressor.rb', line 18

def initialize(io_system = nil)
  @io_system = io_system || System::IOSystem.new
  @quickhelp = QuickHelp::Compressor.new(@io_system)
end

Instance Attribute Details

#io_systemObject (readonly)

Returns the value of attribute io_system.



13
14
15
# File 'lib/cabriolet/hlp/compressor.rb', line 13

def io_system
  @io_system
end

Class Method Details

.create_winhelp(io_system = nil) ⇒ WinHelp::Compressor

Create a Windows Help format HLP file

Parameters:

  • output_file (String)

    Output file path

  • options (Hash)

    Format options

Returns:



57
58
59
# File 'lib/cabriolet/hlp/compressor.rb', line 57

def self.create_winhelp(io_system = nil)
  WinHelp::Compressor.new(io_system)
end

Instance Method Details

#add_data(data, hlp_path, compress: true) ⇒ void

This method returns an undefined value.

Add data from memory

Parameters:

  • data (String)

    Data to add

  • hlp_path (String)

    Path within archive

  • compress (Boolean) (defaults to: true)

    Whether to compress



39
40
41
# File 'lib/cabriolet/hlp/compressor.rb', line 39

def add_data(data, hlp_path, compress: true)
  @quickhelp.add_data(data, hlp_path, compress: compress)
end

#add_file(source_path, hlp_path, compress: true) ⇒ void

This method returns an undefined value.

Add a file to the archive

Parameters:

  • source_path (String)

    Path to source file

  • hlp_path (String)

    Path within archive

  • compress (Boolean) (defaults to: true)

    Whether to compress



29
30
31
# File 'lib/cabriolet/hlp/compressor.rb', line 29

def add_file(source_path, hlp_path, compress: true)
  @quickhelp.add_file(source_path, hlp_path, compress: compress)
end

#generate(output_file, **options) ⇒ Integer

Generate HLP archive (QuickHelp format by default)

Parameters:

  • output_file (String)

    Output file path

  • options (Hash)

    Format options

Returns:

  • (Integer)

    Bytes written



48
49
50
# File 'lib/cabriolet/hlp/compressor.rb', line 48

def generate(output_file, **options)
  @quickhelp.generate(output_file, **options)
end