Class: Uniword::Docx::Reconciler::Fix

Inherits:
Object
  • Object
show all
Defined in:
lib/uniword/docx/reconciler/fix.rb

Overview

A single repair applied by the Reconciler during save.

Immutable value object exposed as the reconciliation report via Package#applied_fixes after a save. The Reconciler stays the only mutating pass; this report is a by-product value, not a global.

Examples:

Inspect fixes after save

package.to_file("out.docx")
package.applied_fixes.each do |fix|
  puts "#{fix.code} [#{fix.part}] #{fix.message}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, message:, part: nil) ⇒ Fix

Create a fix record.

Parameters:

  • code (String)

    Fix code (a FixCodes constant value)

  • message (String)

    Human-readable description of the repair

  • part (String, nil) (defaults to: nil)

    Package part the repair applies to



32
33
34
35
36
# File 'lib/uniword/docx/reconciler/fix.rb', line 32

def initialize(code:, message:, part: nil)
  @code = code
  @message = message
  @part = part
end

Instance Attribute Details

#codeString (readonly)

Returns Fix code (see Reconciler::FixCodes).

Returns:

  • (String)

    Fix code (see Reconciler::FixCodes)



19
20
21
# File 'lib/uniword/docx/reconciler/fix.rb', line 19

def code
  @code
end

#messageString (readonly)

Returns Human-readable description of the repair.

Returns:

  • (String)

    Human-readable description of the repair



22
23
24
# File 'lib/uniword/docx/reconciler/fix.rb', line 22

def message
  @message
end

#partString? (readonly)

Returns Package part the repair applies to.

Returns:

  • (String, nil)

    Package part the repair applies to



25
26
27
# File 'lib/uniword/docx/reconciler/fix.rb', line 25

def part
  @part
end

Instance Method Details

#to_sString

Returns Compact single-line representation.

Returns:

  • (String)

    Compact single-line representation



39
40
41
42
# File 'lib/uniword/docx/reconciler/fix.rb', line 39

def to_s
  location = part ? " [#{part}]" : ""
  "#{code}#{location}: #{message}"
end