Class: Achoo::Achievo::Table

Inherits:
Array
  • Object
show all
Defined in:
lib/achoo/achievo/table.rb

Instance Method Summary collapse

Methods inherited from Array

#merge!

Constructor Details

#initialize(source_rows) ⇒ Table

Returns a new instance of Table.



7
8
9
10
11
12
13
14
# File 'lib/achoo/achievo/table.rb', line 7

def initialize(source_rows)
  super()
  source_rows.each do |tr|
    cells = tr.css('td, th')
    cells = cells.collect {|c| c.content.strip}
    self << fix_empty_cells(cells)
  end
end

Instance Method Details

#select_columns(&block) ⇒ Object



16
17
18
19
20
# File 'lib/achoo/achievo/table.rb', line 16

def select_columns(&block)
  columns = transpose
  columns = columns.select &block
  replace(columns.transpose)
end