Class: Judges::Update::Churn

Inherits:
Object
  • Object
show all
Defined in:
lib/judges/commands/update.rb

Overview

How many facts were modified.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(added, removed) ⇒ Churn

Returns a new instance of Churn.



79
80
81
82
# File 'lib/judges/commands/update.rb', line 79

def initialize(added, removed)
  @added = added
  @removed = removed
end

Instance Attribute Details

#addedObject (readonly)

Returns the value of attribute added.



77
78
79
# File 'lib/judges/commands/update.rb', line 77

def added
  @added
end

#removedObject (readonly)

Returns the value of attribute removed.



77
78
79
# File 'lib/judges/commands/update.rb', line 77

def removed
  @removed
end

Instance Method Details

#+(other) ⇒ Object



92
93
94
# File 'lib/judges/commands/update.rb', line 92

def +(other)
  Churn.new(@added + other.added, @removed + other.removed)
end

#to_sObject



84
85
86
# File 'lib/judges/commands/update.rb', line 84

def to_s
  "#{format('+%d', @added)}/#{format('+%d', -@removed)}"
end

#zero?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/judges/commands/update.rb', line 88

def zero?
  @added.zero? && @removed.zero?
end