class TimeBlock::Agent
Public Class Methods
new(time)
click to toggle source
# File lib/time_block/agent.rb, line 10 def initialize(time) raise MissingPackageError.new('No terminal-notifier, please install it, brew install terminal-notifier') unless terminal_notifier_exist? @time = time end
Public Instance Methods
run()
click to toggle source
# File lib/time_block/agent.rb, line 15 def run pre_callback sleep @time post_callback end
Private Instance Methods
post_callback()
click to toggle source
# File lib/time_block/agent.rb, line 32 def post_callback `terminal-notifier -message #{'Time is out dude !!!'.dump} -title "TimeBlock - #{@time}s" -sound "default"` end
pre_callback()
click to toggle source
# File lib/time_block/agent.rb, line 28 def pre_callback `terminal-notifier -message #{'Time is starting !!!'.dump} -title "TimeBlock - #{@time}s" -sound "default"` end
terminal_notifier_exist?()
click to toggle source
# File lib/time_block/agent.rb, line 23 def terminal_notifier_exist? `which terminal-notifier` $CHILD_STATUS.success? end