Class: Uniword::Diff::PartChange
- Inherits:
-
Object
- Object
- Uniword::Diff::PartChange
- Defined in:
- lib/uniword/diff/package_diff_result.rb
Overview
Value object holding a changed part’s metadata.
Instance Attribute Summary collapse
-
#canon_equivalent ⇒ Object
Returns the value of attribute canon_equivalent.
-
#canon_summary ⇒ Object
Returns the value of attribute canon_summary.
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#new_size ⇒ Object
readonly
Returns the value of attribute new_size.
-
#old_size ⇒ Object
readonly
Returns the value of attribute old_size.
Instance Method Summary collapse
-
#initialize(name:, old_size:, new_size:, changes: [], canon_equivalent: nil, canon_summary: nil) ⇒ PartChange
constructor
A new instance of PartChange.
- #size_delta ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, old_size:, new_size:, changes: [], canon_equivalent: nil, canon_summary: nil) ⇒ PartChange
Returns a new instance of PartChange.
71 72 73 74 75 76 77 78 79 |
# File 'lib/uniword/diff/package_diff_result.rb', line 71 def initialize(name:, old_size:, new_size:, changes: [], canon_equivalent: nil, canon_summary: nil) @name = name @old_size = old_size @new_size = new_size @changes = changes @canon_equivalent = canon_equivalent @canon_summary = canon_summary end |
Instance Attribute Details
#canon_equivalent ⇒ Object
Returns the value of attribute canon_equivalent.
69 70 71 |
# File 'lib/uniword/diff/package_diff_result.rb', line 69 def canon_equivalent @canon_equivalent end |
#canon_summary ⇒ Object
Returns the value of attribute canon_summary.
69 70 71 |
# File 'lib/uniword/diff/package_diff_result.rb', line 69 def canon_summary @canon_summary end |
#changes ⇒ Object
Returns the value of attribute changes.
69 70 71 |
# File 'lib/uniword/diff/package_diff_result.rb', line 69 def changes @changes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
68 69 70 |
# File 'lib/uniword/diff/package_diff_result.rb', line 68 def name @name end |
#new_size ⇒ Object (readonly)
Returns the value of attribute new_size.
68 69 70 |
# File 'lib/uniword/diff/package_diff_result.rb', line 68 def new_size @new_size end |
#old_size ⇒ Object (readonly)
Returns the value of attribute old_size.
68 69 70 |
# File 'lib/uniword/diff/package_diff_result.rb', line 68 def old_size @old_size end |
Instance Method Details
#size_delta ⇒ Object
81 82 83 |
# File 'lib/uniword/diff/package_diff_result.rb', line 81 def size_delta @new_size - @old_size end |
#to_h ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/uniword/diff/package_diff_result.rb', line 85 def to_h result = { name: @name, old_size: @old_size, new_size: @new_size, size_delta: size_delta, } unless @canon_equivalent.nil? result[:canon_equivalent] = @canon_equivalent end result[:canon_summary] = @canon_summary if @canon_summary result[:xml_changes] = @changes.map(&:to_h) if @changes.any? result end |