Class: Rooster::EggTimer
- Inherits:
-
Object
- Object
- Rooster::EggTimer
- Defined in:
- lib/rooster/egg_timer.rb
Constant Summary collapse
- ONE_MINUTE =
60
Instance Method Summary collapse
- #alarm ⇒ Object
-
#initialize(mins, text) ⇒ EggTimer
constructor
A new instance of EggTimer.
- #run ⇒ Object
Constructor Details
#initialize(mins, text) ⇒ EggTimer
Returns a new instance of EggTimer.
7 8 9 10 11 12 13 14 |
# File 'lib/rooster/egg_timer.rb', line 7 def initialize mins, text # @start = Time.now @text = text @mins = mins.to_i run end |
Instance Method Details
#alarm ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/rooster/egg_timer.rb', line 25 def alarm `tput bel` if can_tput TerminalNotifier.notify @text, :title => 'Egg Timer' puts @text # puts "* Duration: #{Time.now - @start} seconds" end |
#run ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/rooster/egg_timer.rb', line 16 def run while @mins > 0 puts "\"#{@text}\" in #{@mins} minutes" sleep ONE_MINUTE @mins -= 1 end alarm end |