Module: ObjectTable::Util

Defined in:
lib/object_table/util.rb

Class Method Summary collapse

Class Method Details

.apply_block(object, block) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/object_table/util.rb', line 3

def self.apply_block(object, block)
  if block.arity == 0
    object.instance_eval(&block)
  else
    block.call(object)
  end
end

.get_rows(table, columns) ⇒ Object



11
12
13
# File 'lib/object_table/util.rb', line 11

def self.get_rows(table, columns)
  columns.map{|n| table[n].to_a}.transpose
end

.group_indices(keys) ⇒ Object



15
16
17
# File 'lib/object_table/util.rb', line 15

def self.group_indices(keys)
  keys.length.times.group_by{|i| keys[i]}
end