Class: ExtractTtc::Models::ExtractionResult
- Inherits:
-
Object
- Object
- ExtractTtc::Models::ExtractionResult
- Defined in:
- lib/extract_ttc/models/extraction_result.rb
Overview
Represents the result of a font extraction operation
This model encapsulates the outcome of extracting fonts from a TTC file, including the list of output files created, success status, and any errors encountered during the process.
This is an immutable value object with methods to query success/failure status.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#output_files ⇒ Object
readonly
Returns the value of attribute output_files.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#add_error(message) ⇒ ExtractionResult
Add an error message to the result.
-
#failure? ⇒ Boolean
Check if the extraction failed.
-
#initialize(output_files: [], success: true, errors: []) ⇒ ExtractionResult
constructor
Initialize a new extraction result.
-
#success? ⇒ Boolean
Check if the extraction was successful.
Constructor Details
#initialize(output_files: [], success: true, errors: []) ⇒ ExtractionResult
Initialize a new extraction result
20 21 22 23 24 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 20 def initialize(output_files: [], success: true, errors: []) @output_files = output_files.freeze @success = success @errors = errors.freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 13 def errors @errors end |
#output_files ⇒ Object (readonly)
Returns the value of attribute output_files.
13 14 15 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 13 def output_files @output_files end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
13 14 15 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 13 def success @success end |
Instance Method Details
#add_error(message) ⇒ ExtractionResult
Add an error message to the result
This creates a new ExtractionResult with the error added, as the object is immutable.
47 48 49 50 51 52 53 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 47 def add_error() self.class.new( output_files: @output_files.dup, success: false, errors: @errors.dup << , ) end |
#failure? ⇒ Boolean
Check if the extraction failed
36 37 38 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 36 def failure? !@success end |
#success? ⇒ Boolean
Check if the extraction was successful
29 30 31 |
# File 'lib/extract_ttc/models/extraction_result.rb', line 29 def success? @success end |