Class: Turnip::StepProfiler::CalledStep

Inherits:
Object
  • Object
show all
Defined in:
lib/turnip/step_profiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stepObject (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_timeObject



27
28
29
# File 'lib/turnip/step_profiler.rb', line 27

def average_time
  total_time / called_count
end

#called_countObject



35
36
37
# File 'lib/turnip/step_profiler.rb', line 35

def called_count
  @called.size
end

#total_timeObject



31
32
33
# File 'lib/turnip/step_profiler.rb', line 31

def total_time
  @called.inject(0.0) {|t, s| t + s.time }
end