Class: Timer
- Inherits:
-
Object
- Object
- Timer
- Defined in:
- lib/timer.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :growl => true }
Instance Attribute Summary collapse
-
#growl ⇒ Object
writeonly
Sets the attribute growl.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #growl? ⇒ Boolean
-
#initialize(options = {}) ⇒ Timer
constructor
A new instance of Timer.
- #time(message = "", options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Timer
Returns a new instance of Timer.
10 11 12 13 14 |
# File 'lib/timer.rb', line 10 def initialize(={}) = DEFAULT_OPTIONS.merge() @title = [:title] @growl = [:growl] end |
Instance Attribute Details
#growl=(value) ⇒ Object
Sets the attribute growl
6 7 8 |
# File 'lib/timer.rb', line 6 def growl=(value) @growl = value end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/timer.rb', line 6 def title @title end |
Instance Method Details
#growl? ⇒ Boolean
28 29 30 |
# File 'lib/timer.rb', line 28 def growl? @growl end |
#time(message = "", options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/timer.rb', line 16 def time(="", ={}) current_title = [:title] || title start_time = Time.now begin yield rescue StandardError => e end put_elapsed_time(start_time, Time.now, , current_title) raise e if e end |