Class: WeasyRb::Converter
- Inherits:
-
Object
- Object
- WeasyRb::Converter
- Defined in:
- lib/weasy_rb/converter.rb
Overview
Main converter class responsible for orchestrating HTML to PDF conversion Follows Single Responsibility Principle by focusing only on conversion logic
Instance Method Summary collapse
-
#convert(html, output_path, options = {}) ⇒ String
Converts HTML content to PDF file.
-
#initialize(command_builder: CommandBuilder.new, executor: Executor.new) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(command_builder: CommandBuilder.new, executor: Executor.new) ⇒ Converter
Returns a new instance of Converter.
7 8 9 10 |
# File 'lib/weasy_rb/converter.rb', line 7 def initialize(command_builder: CommandBuilder.new, executor: Executor.new) @command_builder = command_builder @executor = executor end |
Instance Method Details
#convert(html, output_path, options = {}) ⇒ String
Converts HTML content to PDF file
17 18 19 20 21 22 23 24 |
# File 'lib/weasy_rb/converter.rb', line 17 def convert(html, output_path, = {}) validate_inputs(html, output_path) command = @command_builder.build(output_path, ) result = @executor.execute(command, html) handle_result(result, output_path) end |