Class: TimerCli::Command::TimerCommand

Inherits:
BaseCommand show all
Defined in:
lib/timer_cli/command/timer_command.rb

Overview

timer command execution class

Instance Method Summary collapse

Methods inherited from BaseCommand

execute

Instance Method Details

#execute(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/timer_cli/command/timer_command.rb', line 10

def execute(params)
  super

  parse_time_and_unit!

  start_time = Time.now
  finish_time = time.send(unit).from_now

  prepare_clock(start: start_time, finish: finish_time)

  puts "#{[name, timer].join(' ')} - #{start_time.strftime('%H:%M:%S')}"

  (0..clock).each do
    break if $timer_cli_terminate

    sleep(1)
    progressbar.advance unless $timer_cli_terminate
  end

  puts "Timer #{name} finished at #{finish_time}" unless $timer_cli_terminate
end