Sha256: 86904adb9b783654e5f0fb4c706b8b0cc9808935bf4cd0eb47c4bc9fe86bbdaa

Contents?: true

Size: 879 Bytes

Versions: 19

Compression:

Stored size: 879 Bytes

Contents

%w(table).each do |path|
  MetricFu.metrics_require   { "hotspots/analysis/#{path}" }
end
module MetricFu
  class Grouping

    def initialize(table, opts)
      column_name = opts.fetch(:by)
      order = opts.fetch(:order) { nil }
      hash = {}
      if column_name.to_sym == :metric # special optimized case
        hash = table.group_by_metric
      else
        table.each do |row|
          hash[row[column_name]] ||= MetricFu::Table.new(:column_names => row.attributes)
          hash[row[column_name]] << row
        end
      end
      if order
        @arr = hash.sort_by(&order)
      else
        @arr = hash.to_a
      end
    end

    def [](key)
      @arr.each do |group_key, table|
        return table if group_key == key
      end
      return nil
    end

    def each
      @arr.each do |value, rows|
        yield value, rows
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
metric_fu-4.4.0 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.3.1 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.3.0 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.2.1 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.2.0 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.1.3 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.1.2 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.1.1 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.1.0 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-4.0.0 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-3.0.1 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-3.0.0 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.4.pre5 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.4.pre4 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.4.pre2 lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.4.pre lib/metric_fu/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.3.7.18.1 lib/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.3.7.19 lib/metrics/hotspots/analysis/grouping.rb
metric_fu-2.1.3.6 lib/metrics/hotspots/analysis/grouping.rb