Class: Judges::Churn
Overview
How many facts were modified.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Attribute Summary collapse
-
#added ⇒ Object
readonly
Returns the value of attribute added.
-
#removed ⇒ Object
readonly
Returns the value of attribute removed.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
-
#initialize(added, removed) ⇒ Churn
constructor
A new instance of Churn.
- #to_s ⇒ Object
- #zero? ⇒ Boolean
Constructor Details
#initialize(added, removed) ⇒ Churn
Returns a new instance of Churn.
32 33 34 35 |
# File 'lib/judges/churn.rb', line 32 def initialize(added, removed) @added = added @removed = removed 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 |
#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
45 46 47 48 49 50 51 |
# File 'lib/judges/churn.rb', line 45 def +(other) if other.is_a?(Judges::Churn) Judges::Churn.new(@added + other.added, @removed + other.removed) else Judges::Churn.new(@added + other, @removed) end end |
#-(other) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/judges/churn.rb', line 53 def -(other) if other.is_a?(Judges::Churn) Judges::Churn.new(@added - other.added, @removed - other.removed) else Judges::Churn.new(@added, @removed + other) end end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/judges/churn.rb', line 37 def to_s "#{@added}/#{@removed}" end |
#zero? ⇒ Boolean
41 42 43 |
# File 'lib/judges/churn.rb', line 41 def zero? @added.zero? && @removed.zero? end |