class MetricFu::Table
Public Class Methods
new(opts = {})
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 9 def initialize(opts = {}) @rows = [] @columns = opts.fetch(:column_names) @make_index = opts.fetch(:make_index) { true } @metric_index = {} end
Public Instance Methods
<<(row)
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 17 def <<(row) record = nil if row.is_a?(MetricFu::Record) record = row else record = MetricFu::Record.new(row, @columns) end @rows << record updated_key_index(record) if @make_index end
[](index)
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 42 def [](index) @rows[index] end
column(column_name)
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 46 def column(column_name) arr = [] @rows.each do |row| arr << row[column_name] end arr end
each() { |row| ... }
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 28 def each @rows.each do |row| yield row end end
group_by_metric()
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 54 def group_by_metric @metric_index.to_a end
length()
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 38 def length @rows.length end
size()
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 34 def size length end
Private Instance Methods
updated_key_index(record)
click to toggle source
# File lib/metric_fu/metrics/hotspots/analysis/table.rb, line 60 def updated_key_index(record) if record.has_key?("metric") @metric_index[record.metric] ||= MetricFu::Table.new(column_names: @columns, make_index: false) @metric_index[record.metric] << record end end