Class: Ritsudo::Result::Misc

Inherits:
Object
  • Object
show all
Defined in:
lib/ritsudo/result/misc.rb

Instance Method Summary collapse

Constructor Details

#initializeMisc

Returns a new instance of Misc.



4
5
6
# File 'lib/ritsudo/result/misc.rb', line 4

def initialize
  @misc = {}
end

Instance Method Details

#add(group, name, value) ⇒ Object



8
9
10
11
12
# File 'lib/ritsudo/result/misc.rb', line 8

def add(group, name, value)
  @misc[group] ||= {}
  @misc[group][name] ||= []
  @misc[group][name] << value
end

#report(outliters_stdev_multiple: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ritsudo/result/misc.rb', line 14

def report(outliters_stdev_multiple: nil)
  table_data = []
  @misc.each do |group, name_and_values|
    puts "[#{group}]"

    name_and_values.each do |name, all_values|
      use_remove_outsiders = outliters_stdev_multiple && all_values.size > 1
      if use_remove_outsiders
        values = Ritsudo::Result::Helper.remove_outliters(all_values, outliters_stdev_multiple)
      else
        values = all_values
      end

      result = {
        name: name,
        avg: (values.sum(0.0) / values.length)&.round(2),
        max: values.max&.round(2),
        min: values.min&.round(2),
        count: values.size,
        outliters: all_values.size - values.size
      }


      table_data << result
    end
    Formatador.display_table(table_data, [:name, :avg, :max, :min, :count, :outliters])
  end
end