Class: Excelerate::Worksheet

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
ParentReader
Defined in:
lib/excelerate/worksheet.rb

Defined Under Namespace

Classes: Cell

Constant Summary collapse

AS_CELL =
proc { |cell| Cell.new(:cell => cell) }

Instance Method Summary collapse

Methods included from ParentReader

parent_reader

Constructor Details

#initialize(options = {}) ⇒ Worksheet



9
10
11
# File 'lib/excelerate/worksheet.rb', line 9

def initialize(options = {})
  __setobj__ options[:worksheet]
end

Instance Method Details

#column(index) ⇒ Object



21
22
23
# File 'lib/excelerate/worksheet.rb', line 21

def column(index)
  columns[index]
end

#column_headersObject



33
34
35
# File 'lib/excelerate/worksheet.rb', line 33

def column_headers
  rows.first.map(&AS_CELL)
end

#columnsObject



17
18
19
# File 'lib/excelerate/worksheet.rb', line 17

def columns
  cells.transpose.map { |c| c.map(&AS_CELL) }
end

#each_cell(&block) ⇒ Object



13
14
15
# File 'lib/excelerate/worksheet.rb', line 13

def each_cell(&block)
  cells.flatten.map(&AS_CELL).each &block
end

#row(index) ⇒ Object



29
30
31
# File 'lib/excelerate/worksheet.rb', line 29

def row(index)
  rows[index]
end

#rowsObject



25
26
27
# File 'lib/excelerate/worksheet.rb', line 25

def rows
  cells.map { |c| c.map(&AS_CELL) }
end