Class: PVN::DiffCount

Inherits:
Object
  • Object
show all
Defined in:
lib/pvn/util/diffcount.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fromObject (readonly)

Returns the value of attribute from.



6
7
8
# File 'lib/pvn/util/diffcount.rb', line 6

def from
  @from
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/pvn/util/diffcount.rb', line 8

def name
  @name
end

#toObject (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


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