class Rooster::EggTimer
Constants
- ONE_MINUTE
Public Class Methods
new(minutes, text)
click to toggle source
Start your egg timer
Example:
>> rooster 10, "remind me to make coffee in ten minutes"
Arguments:
minutes: (Integer) text: (String)
# File lib/rooster/egg_timer.rb, line 15 def initialize minutes, text @text = text @minutes = minutes.to_i run end
Private Instance Methods
alarm()
click to toggle source
# File lib/rooster/egg_timer.rb, line 33 def alarm beep_it say_it notification_center_it display_it end
beep_it()
click to toggle source
# File lib/rooster/egg_timer.rb, line 40 def beep_it `which tput` `tput bel` if $?.success? end
display_it()
click to toggle source
# File lib/rooster/egg_timer.rb, line 58 def display_it puts "\nTime's up.".green puts "\"#{@text}\"".green end
notification_center_it()
click to toggle source
# File lib/rooster/egg_timer.rb, line 50 def notification_center_it begin TerminalNotifier.notify @text, :title => 'Egg Timer' rescue Exception => e # TerminalNotifier::UnsupportedPlatformError end end
run()
click to toggle source
# File lib/rooster/egg_timer.rb, line 24 def run while @minutes > 0 puts "=> #{@minutes} minute remaining until \"#{@text}\"." sleep ONE_MINUTE @minutes -= 1 end alarm end
say_it()
click to toggle source
# File lib/rooster/egg_timer.rb, line 45 def say_it `which say` `say #{@text}` if $?.success? end