Class: Uniword::Diff::Semantic::Result
- Inherits:
-
Object
- Object
- Uniword::Diff::Semantic::Result
- Defined in:
- lib/uniword/diff/semantic/result.rb
Overview
Aggregated semantic diff result. Counts by kind and modifier; full change list.
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
Instance Method Summary collapse
- #add(change) ⇒ void
-
#by_kind ⇒ Hash{Symbol => Integer}
Count by kind (
:added,:removed,:modified,:moved). -
#by_modifier ⇒ Hash{Symbol => Integer}
For modified changes, count by modifier (
:text,:format,:structure). -
#count ⇒ Integer
Total change count.
-
#empty? ⇒ Boolean
True when no changes.
-
#initialize ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
11 12 13 |
# File 'lib/uniword/diff/semantic/result.rb', line 11 def initialize @changes = [] end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
9 10 11 |
# File 'lib/uniword/diff/semantic/result.rb', line 9 def changes @changes end |
Instance Method Details
#add(change) ⇒ void
This method returns an undefined value.
17 18 19 |
# File 'lib/uniword/diff/semantic/result.rb', line 17 def add(change) @changes << change end |
#by_kind ⇒ Hash{Symbol => Integer}
Count by kind (:added, :removed, :modified, :moved).
24 25 26 |
# File 'lib/uniword/diff/semantic/result.rb', line 24 def by_kind @changes.group_by(&:kind).transform_values(&:count) end |
#by_modifier ⇒ Hash{Symbol => Integer}
For modified changes, count by modifier (:text,
:format, :structure).
32 33 34 35 |
# File 'lib/uniword/diff/semantic/result.rb', line 32 def by_modifier modified = @changes.select { |c| c.kind == :modified } modified.group_by(&:modifier).transform_values(&:count) end |
#count ⇒ Integer
Total change count.
40 41 42 |
# File 'lib/uniword/diff/semantic/result.rb', line 40 def count @changes.length end |
#empty? ⇒ Boolean
True when no changes.
47 48 49 |
# File 'lib/uniword/diff/semantic/result.rb', line 47 def empty? @changes.empty? end |