Class: TomatoHarvest::Timer
- Inherits:
-
Object
- Object
- TomatoHarvest::Timer
- Defined in:
- lib/tomatoharvest/timer.rb
Constant Summary collapse
- SLEEP_LENGTH =
1
- PID_NAME =
'pid'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(list, task_id, options = {}) ⇒ Timer
constructor
A new instance of Timer.
- #start ⇒ Object
Constructor Details
#initialize(list, task_id, options = {}) ⇒ Timer
Returns a new instance of Timer.
19 20 21 22 23 24 25 26 27 |
# File 'lib/tomatoharvest/timer.rb', line 19 def initialize(list, task_id, = {}) @minutes = [:minutes] @time_entry = [:time_entry] @notifier = Notifier.new @list = list @task = @list.find(task_id) @timer = 0 @tmux = Tmux.new end |
Class Method Details
.pid_dir ⇒ Object
39 40 41 |
# File 'lib/tomatoharvest/timer.rb', line 39 def self.pid_dir TomatoHarvest::Config::GLOBAL_DIR end |
.start(*args) ⇒ Object
8 9 10 |
# File 'lib/tomatoharvest/timer.rb', line 8 def self.start(*args) new(*args).start end |
.stop ⇒ Object
12 13 14 15 16 17 |
# File 'lib/tomatoharvest/timer.rb', line 12 def self.stop if monitor = Daemons::Monitor.find(pid_dir, PID_NAME) monitor.stop true end end |
Instance Method Details
#start ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/tomatoharvest/timer.rb', line 29 def start if Daemons.daemonize(app_name: PID_NAME, dir: self.class.pid_dir, dir_mode: :normal) at_exit { save_and_log } run_timer else run_timer save_and_log end end |