Class: Judges::Churn
Overview
How many facts were modified.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Attribute Summary collapse
-
#added ⇒ Object
readonly
Returns the value of attribute added.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#removed ⇒ Object
readonly
Returns the value of attribute removed.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<<(error) ⇒ Object
-
#initialize(added, removed, errors = []) ⇒ Churn
constructor
A new instance of Churn.
- #to_s ⇒ Object
- #zero? ⇒ Boolean
Constructor Details
#initialize(added, removed, errors = []) ⇒ Churn
Returns a new instance of Churn.
32 33 34 35 36 |
# File 'lib/judges/churn.rb', line 32 def initialize(added, removed, errors = []) @added = added @removed = removed @errors = errors end |
Instance Attribute Details
#added ⇒ Object (readonly)
Returns the value of attribute added.
30 31 32 |
# File 'lib/judges/churn.rb', line 30 def added @added end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
30 31 32 |
# File 'lib/judges/churn.rb', line 30 def errors @errors end |
#removed ⇒ Object (readonly)
Returns the value of attribute removed.
30 31 32 |
# File 'lib/judges/churn.rb', line 30 def removed @removed end |
Instance Method Details
#+(other) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/judges/churn.rb', line 51 def +(other) if other.is_a?(Judges::Churn) Judges::Churn.new(@added + other.added, @removed + other.removed, @errors + other.errors) else Judges::Churn.new(@added + other, @removed, @errors) end end |
#-(other) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/judges/churn.rb', line 59 def -(other) if other.is_a?(Judges::Churn) Judges::Churn.new(@added - other.added, @removed - other.removed, @errors + other.errors) else Judges::Churn.new(@added, @removed + other, @errors) end end |
#<<(error) ⇒ Object
46 47 48 49 |
# File 'lib/judges/churn.rb', line 46 def <<(error) @errors << error nil end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/judges/churn.rb', line 38 def to_s "#{@added}/#{@removed}#{@errors.empty? ? '' : "/#{@errors.size}"}" end |
#zero? ⇒ Boolean
42 43 44 |
# File 'lib/judges/churn.rb', line 42 def zero? @added.zero? && @removed.zero? && @errors.empty? end |