Class: Pandocomatic::FinishPrinter

Inherits:
SummaryPrinter show all
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

Methods inherited from SummaryPrinter

#commands, #output?

Methods inherited from Printer

#print, #template, #to_s

Constructor Details

#initialize(command, configuration, start_time) ⇒ FinishPrinter

Create a new FinishPrinter

pandocomatic invokation

Parameters:

  • command (Command)

    the command to finish

  • configuration (Configuration)

    the configuration of the

  • start_time (Time)

    the time the command was started



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

#durationNumber

Calculate the duration of the whole conversion process

Returns:

  • (Number)


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