Class: WeasyRb::CommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/weasy_rb/command_builder.rb

Overview

Responsible for building WeasyPrint command strings Follows Single Responsibility Principle and Open/Closed Principle

Constant Summary collapse

WEASY_PRINT_COMMAND =
"weasyprint"

Instance Method Summary collapse

Instance Method Details

#build(output_path, options = {}) ⇒ Array<String>

Build WeasyPrint command with options

Parameters:

  • output_path (String)

    Path where the PDF will be saved

  • options (Hash) (defaults to: {})

    Additional options for WeasyPrint

Returns:

  • (Array<String>)

    Command array ready for execution



13
14
15
16
17
18
19
# File 'lib/weasy_rb/command_builder.rb', line 13

def build(output_path, options = {})
  command = [WEASY_PRINT_COMMAND]
  command.concat(build_options(options))
  command << "-" # Read from stdin
  command << output_path
  command
end