Class: Archiver::Output::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/archiver/output/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbose) ⇒ Cli

Returns a new instance of Cli.



16
17
18
19
20
# File 'lib/archiver/output/cli.rb', line 16

def initialize(verbose)
  @verbose = verbose
  @count = 0
  @working = 0
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



12
13
14
# File 'lib/archiver/output/cli.rb', line 12

def count
  @count
end

#progressObject

Returns the value of attribute progress.



14
15
16
# File 'lib/archiver/output/cli.rb', line 14

def progress
  @progress
end

#verboseObject

Returns the value of attribute verbose.



11
12
13
# File 'lib/archiver/output/cli.rb', line 11

def verbose
  @verbose
end

#workingObject

Returns the value of attribute working.



13
14
15
# File 'lib/archiver/output/cli.rb', line 13

def working
  @working
end

Instance Method Details

#finish!Object



37
38
39
40
41
42
43
# File 'lib/archiver/output/cli.rb', line 37

def finish!
  if verbose
    puts "Processed #{count} records!"
  else
    progress.finish
  end
end

#process(record) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/archiver/output/cli.rb', line 27

def process(record)
  @working += 1
  
  if verbose
    puts "#{sprintf('%05d', @working)}/#{sprintf('%05d', count)}: #{record.path} -> #{record.filename}"
  else
    progress.inc
  end
end