Class: Builtins::Countdown

Inherits:
Builtin
  • Object
show all
Defined in:
lib/builtins/countdown.rb

Constant Summary collapse

USAGE_STRING =
"Usage: ops countdown <seconds>"

Instance Attribute Summary

Attributes inherited from Builtin

#args, #config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Builtin

class_for, #initialize

Constructor Details

This class inherits a constructor from Builtin

Class Method Details

.descriptionObject


13
14
15
# File 'lib/builtins/countdown.rb', line 13

def description
	"Like `sleep`, but displays time remaining in terminal."
end

Instance Method Details

#runObject


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/builtins/countdown.rb', line 18

def run
	check_args

	timer_task.execute

	while timer_task.running?
		sleep(1)
		timer_task.shutdown if task_complete?
	end
	Output.out("\rCountdown complete after #{sleep_seconds}s.")
end