Class: Pandocomatic::FinishPrinter
- Inherits:
-
SummaryPrinter
- Object
- Printer
- SummaryPrinter
- Pandocomatic::FinishPrinter
- Defined in:
- lib/pandocomatic/printer/finish_printer.rb
Overview
Printer for the end of the conversion process in non-quiet mode
Constant Summary collapse
- MINUTE =
A minute has 60 seconds
60
Instance Method Summary collapse
-
#duration ⇒ Number
Calculate the duration of the whole conversion process.
-
#initialize(command, configuration, start_time) ⇒ FinishPrinter
constructor
Create a new FinishPrinter.
Methods inherited from SummaryPrinter
Methods inherited from Printer
Constructor Details
#initialize(command, configuration, start_time) ⇒ FinishPrinter
Create a new FinishPrinter
pandocomatic invokation
35 36 37 38 39 40 41 |
# File 'lib/pandocomatic/printer/finish_printer.rb', line 35 def initialize(command, configuration, start_time) super(command, configuration) template 'finish.txt' @start_time = start_time @end_time = Time.now end |
Instance Method Details
#duration ⇒ Number
Calculate the duration of the whole conversion process
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pandocomatic/printer/finish_printer.rb', line 46 def duration seconds = @end_time - @start_time if seconds > MINUTE minutes = (seconds / MINUTE).floor seconds -= (minutes * MINUTE) "#{minutes} minute#{'s' if minutes != 1} and #{seconds.round(1)} second#{'s' if seconds != 1}" else "#{seconds.round(1)} second#{'s' if seconds != 1}" end end |