Class: Metriks::Timer::Context
- Inherits:
-
Object
- Object
- Metriks::Timer::Context
- Defined in:
- lib/metriks/timer.rb
Instance Method Summary collapse
-
#activate_reset_on_submit ⇒ Object
shortcut for onliners.
-
#initialize(timer) ⇒ Context
constructor
A new instance of Context.
- #restart ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(timer) ⇒ Context
Returns a new instance of Context.
12 13 14 15 |
# File 'lib/metriks/timer.rb', line 12 def initialize(timer) @timer = timer @interval = Hitimes::Interval.now end |
Instance Method Details
#activate_reset_on_submit ⇒ Object
shortcut for onliners
17 18 19 20 |
# File 'lib/metriks/timer.rb', line 17 def activate_reset_on_submit @reset_on_submit = true self end |
#restart ⇒ Object
22 23 24 |
# File 'lib/metriks/timer.rb', line 22 def restart @interval = Hitimes::Interval.now end |
#stop ⇒ Object
26 27 28 29 |
# File 'lib/metriks/timer.rb', line 26 def stop @interval.stop @timer.update(@interval.duration) end |