Class: Archiver::Output::Cli
- Inherits:
-
Object
- Object
- Archiver::Output::Cli
- Defined in:
- lib/archiver/output/cli.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#working ⇒ Object
Returns the value of attribute working.
Instance Method Summary collapse
- #finish! ⇒ Object
-
#initialize(verbose) ⇒ Cli
constructor
A new instance of Cli.
- #process(record) ⇒ Object
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
#count ⇒ Object
Returns the value of attribute count.
12 13 14 |
# File 'lib/archiver/output/cli.rb', line 12 def count @count end |
#progress ⇒ Object
Returns the value of attribute progress.
14 15 16 |
# File 'lib/archiver/output/cli.rb', line 14 def progress @progress end |
#verbose ⇒ Object
Returns the value of attribute verbose.
11 12 13 |
# File 'lib/archiver/output/cli.rb', line 11 def verbose @verbose end |
#working ⇒ Object
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 |