Class: TestProf::FactoryProf::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/test_prof/factory_prof.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stacks, raw_stats) ⇒ Result

Returns a new instance of Result.



28
29
30
31
# File 'lib/test_prof/factory_prof.rb', line 28

def initialize(stacks, raw_stats)
  @stacks = stacks
  @raw_stats = raw_stats
end

Instance Attribute Details

#raw_statsObject (readonly)

Returns the value of attribute raw_stats.



26
27
28
# File 'lib/test_prof/factory_prof.rb', line 26

def raw_stats
  @raw_stats
end

#stacksObject (readonly)

Returns the value of attribute stacks.



26
27
28
# File 'lib/test_prof/factory_prof.rb', line 26

def stacks
  @stacks
end

Instance Method Details

#statsObject

Returns sorted stats



34
35
36
37
38
39
# File 'lib/test_prof/factory_prof.rb', line 34

def stats
  return @stats if instance_variable_defined?(:@stats)

  @stats = @raw_stats.values
                     .sort_by { |el| -el[:total] }
end

#totalObject



41
42
43
44
# File 'lib/test_prof/factory_prof.rb', line 41

def total
  return @total if instance_variable_defined?(:@total)
  @total = @raw_stats.values.sum { |v| v[:total] }
end