Class: Renamr::Reporter
- Inherits:
-
Object
- Object
- Renamr::Reporter
- Defined in:
- lib/renamr/reporter.rb
Overview
Formats and prints output data.
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #add(lhs, rhs) ⇒ Object
- #do ⇒ Object
-
#initialize(dir) ⇒ Reporter
constructor
A new instance of Reporter.
Constructor Details
#initialize(dir) ⇒ Reporter
Returns a new instance of Reporter.
23 24 25 26 |
# File 'lib/renamr/reporter.rb', line 23 def initialize(dir) @dir = dir @row = [] end |
Class Method Details
.final ⇒ Object
61 62 63 64 65 |
# File 'lib/renamr/reporter.rb', line 61 def self.final msg = "#{@@act ? 'Real' : 'Test'}:#{stat_out} in #{@@tim.read}." msg = Utils.trim(msg, @@ttl) puts "| #{msg}#{' ' * (@@ttl - msg.length)} |\n+-#{'-' * @@ttl}-+" end |
.init(act, wid) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/renamr/reporter.rb', line 16 def self.init(act, wid) @@act = act @@tbl = wid @@ttl = wid - 4 @@str = (wid - 7) / 2 end |
.stat_out ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/renamr/reporter.rb', line 53 def self.stat_out out = '' @@sta.each do |k, v| out += ' ' + v.to_s + ' ' + k.to_s + ',' if v.positive? end out.chop end |
Instance Method Details
#add(lhs, rhs) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/renamr/reporter.rb', line 28 def add(lhs, rhs) if rhs.is_a?(StandardError) tag = :failed rhs = "#{rhs.} (#{rhs.class})" elsif rhs == '' tag = :unaltered else tag = :moved end @@sta[tag] += 1 @row << [Utils.trim(lhs, @@str), Utils.trim(rhs, @@str)] end |