Class: MetricFu::Table
- Inherits:
-
Object
- Object
- MetricFu::Table
- Includes:
- Enumerable
- Defined in:
- lib/metric_fu/metrics/hotspots/analysis/table.rb
Instance Method Summary collapse
- #<<(row) ⇒ Object
- #[](index) ⇒ Object
- #column(column_name) ⇒ Object
- #each ⇒ Object
- #group_by_metric ⇒ Object
-
#initialize(opts = {}) ⇒ Table
constructor
A new instance of Table.
- #length ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Table
Returns a new instance of Table.
9 10 11 12 13 14 15 |
# 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 |
Instance Method Details
#<<(row) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# 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) ⇒ Object
42 43 44 |
# File 'lib/metric_fu/metrics/hotspots/analysis/table.rb', line 42 def [](index) @rows[index] end |
#column(column_name) ⇒ Object
46 47 48 49 50 51 52 |
# 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 ⇒ Object
28 29 30 31 32 |
# File 'lib/metric_fu/metrics/hotspots/analysis/table.rb', line 28 def each @rows.each do |row| yield row end end |
#group_by_metric ⇒ Object
54 55 56 |
# File 'lib/metric_fu/metrics/hotspots/analysis/table.rb', line 54 def group_by_metric @metric_index.to_a end |
#length ⇒ Object
38 39 40 |
# File 'lib/metric_fu/metrics/hotspots/analysis/table.rb', line 38 def length @rows.length end |
#size ⇒ Object
34 35 36 |
# File 'lib/metric_fu/metrics/hotspots/analysis/table.rb', line 34 def size length end |