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