Class: Turnip::StepProfiler::CalledStep
- Inherits:
-
Object
- Object
- Turnip::StepProfiler::CalledStep
- Defined in:
- lib/turnip/step_profiler.rb
Instance Attribute Summary collapse
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
- #<<(step_execute) ⇒ Object
- #average_time ⇒ Object
- #called_count ⇒ Object
-
#initialize(step) ⇒ CalledStep
constructor
A new instance of CalledStep.
- #total_time ⇒ Object
Constructor Details
#initialize(step) ⇒ CalledStep
Returns a new instance of CalledStep.
18 19 20 21 |
# File 'lib/turnip/step_profiler.rb', line 18 def initialize(step) @step = step @called = [] end |
Instance Attribute Details
#step ⇒ Object (readonly)
Returns the value of attribute step.
16 17 18 |
# File 'lib/turnip/step_profiler.rb', line 16 def step @step end |
Instance Method Details
#<<(step_execute) ⇒ Object
23 24 25 |
# File 'lib/turnip/step_profiler.rb', line 23 def <<(step_execute) @called << step_execute end |
#average_time ⇒ Object
27 28 29 |
# File 'lib/turnip/step_profiler.rb', line 27 def average_time total_time / called_count end |
#called_count ⇒ Object
35 36 37 |
# File 'lib/turnip/step_profiler.rb', line 35 def called_count @called.size end |
#total_time ⇒ Object
31 32 33 |
# File 'lib/turnip/step_profiler.rb', line 31 def total_time @called.inject(0.0) {|t, s| t + s.time } end |