Class: PVN::DiffCount
- Inherits:
-
Object
- Object
- PVN::DiffCount
- Defined in:
- lib/pvn/util/diffcount.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #<<(diff) ⇒ Object
-
#initialize(from = 0, to = 0, name = nil) ⇒ DiffCount
constructor
A new instance of DiffCount.
- #print(name = @name) ⇒ Object
Constructor Details
#initialize(from = 0, to = 0, name = nil) ⇒ DiffCount
Returns a new instance of DiffCount.
10 11 12 13 14 |
# File 'lib/pvn/util/diffcount.rb', line 10 def initialize from = 0, to = 0, name = nil @from = from @to = to @name = name end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'lib/pvn/util/diffcount.rb', line 6 def from @from end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/pvn/util/diffcount.rb', line 8 def name @name end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
7 8 9 |
# File 'lib/pvn/util/diffcount.rb', line 7 def to @to end |
Instance Method Details
#<<(diff) ⇒ Object
23 24 25 26 |
# File 'lib/pvn/util/diffcount.rb', line 23 def << diff @from += diff.from @to += diff.to end |
#print(name = @name) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/pvn/util/diffcount.rb', line 16 def print name = @name diff = to - from diffpct = diff == 0 ? 0 : 100.0 * diff / from $io.printf "%8d %8d %8d %8.1f%% %s\n", from, to, diff, diffpct, name end |