Class: Timer
- Inherits:
-
Object
- Object
- Timer
- Defined in:
- lib/yuris-timer.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(args) ⇒ Timer
constructor
A new instance of Timer.
- #start ⇒ Object
- #title ⇒ Object
- #total_seconds ⇒ Object
Constructor Details
#initialize(args) ⇒ Timer
Returns a new instance of Timer.
4 5 6 7 |
# File 'lib/yuris-timer.rb', line 4 def initialize(args) @number_of_minutes, *@message = *args @message = @message.join(" ") end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
2 3 4 |
# File 'lib/yuris-timer.rb', line 2 def @message end |
Instance Method Details
#start ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/yuris-timer.rb', line 17 def start pid = fork do sleep(total_seconds) `terminal-notifier -title "#{title}" -message "#{}"` end Process.detach(pid) end |
#title ⇒ Object
9 10 11 |
# File 'lib/yuris-timer.rb', line 9 def title "#{@number_of_minutes.to_i} min timer elapsed" end |
#total_seconds ⇒ Object
26 27 28 |
# File 'lib/yuris-timer.rb', line 26 def total_seconds (@number_of_minutes.to_f * 60).to_i end |