Class: Uniword::FormatConverter::ConversionResult
- Inherits:
-
Object
- Object
- Uniword::FormatConverter::ConversionResult
- Defined in:
- lib/uniword/format_converter.rb
Overview
Result object for conversion operations.
Explicitly reports what happened during conversion. No hidden state - all information is accessible.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#images_count ⇒ Object
readonly
Returns the value of attribute images_count.
-
#paragraphs_count ⇒ Object
readonly
Returns the value of attribute paragraphs_count.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_format ⇒ Object
readonly
Returns the value of attribute source_format.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#tables_count ⇒ Object
readonly
Returns the value of attribute tables_count.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_format ⇒ Object
readonly
Returns the value of attribute target_format.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ ConversionResult
constructor
Initialize conversion result.
-
#success? ⇒ Boolean
Check if conversion succeeded.
-
#to_h ⇒ Hash
Get detailed result as hash.
-
#to_s ⇒ String
Get human-readable result summary.
Constructor Details
#initialize(attributes) ⇒ ConversionResult
Initialize conversion result
204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/uniword/format_converter.rb', line 204 def initialize(attributes) @source = attributes[:source] @source_format = attributes[:source_format] @target = attributes[:target] @target_format = attributes[:target_format] @success = attributes[:success] @paragraphs_count = attributes[:paragraphs_count] || 0 @tables_count = attributes[:tables_count] || 0 @images_count = attributes[:images_count] || 0 @error = attributes[:error] end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def error @error end |
#images_count ⇒ Object (readonly)
Returns the value of attribute images_count.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def images_count @images_count end |
#paragraphs_count ⇒ Object (readonly)
Returns the value of attribute paragraphs_count.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def paragraphs_count @paragraphs_count end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def source @source end |
#source_format ⇒ Object (readonly)
Returns the value of attribute source_format.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def source_format @source_format end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def success @success end |
#tables_count ⇒ Object (readonly)
Returns the value of attribute tables_count.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def tables_count @tables_count end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def target @target end |
#target_format ⇒ Object (readonly)
Returns the value of attribute target_format.
197 198 199 |
# File 'lib/uniword/format_converter.rb', line 197 def target_format @target_format end |
Instance Method Details
#success? ⇒ Boolean
Check if conversion succeeded
219 220 221 |
# File 'lib/uniword/format_converter.rb', line 219 def success? @success end |
#to_h ⇒ Hash
Get detailed result as hash
239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/uniword/format_converter.rb', line 239 def to_h { source: source, source_format: source_format, target: target, target_format: target_format, success: success, paragraphs_count: paragraphs_count, tables_count: tables_count, images_count: images_count, error: error } end |
#to_s ⇒ String
Get human-readable result summary
226 227 228 229 230 231 232 233 234 |
# File 'lib/uniword/format_converter.rb', line 226 def to_s if success? "Conversion: #{source_format} → #{target_format} " \ "(#{paragraphs_count} paragraphs, #{tables_count} tables, " \ "#{images_count} images) - SUCCESS" else "Conversion: #{source_format} → #{target_format} - FAILED: #{error}" end end |