Class: Osheet::Worksheet

Inherits:
Object
  • Object
show all
Includes:
MetaElement
Defined in:
lib/osheet/worksheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MetaElement

#meta

Constructor Details

#initialize(name = nil, *args) ⇒ Worksheet

Returns a new instance of Worksheet.



16
17
18
19
20
# File 'lib/osheet/worksheet.rb', line 16

def initialize(name=nil, *args)
  @name = name
  @columns = []
  @rows = []
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



14
15
16
# File 'lib/osheet/worksheet.rb', line 14

def columns
  @columns
end

#rowsObject (readonly)

Returns the value of attribute rows.



14
15
16
# File 'lib/osheet/worksheet.rb', line 14

def rows
  @rows
end

Instance Method Details

#column(column_obj) ⇒ Object



26
27
28
# File 'lib/osheet/worksheet.rb', line 26

def column(column_obj)
  @columns << column_obj
end

#name(value = nil) ⇒ Object



22
23
24
# File 'lib/osheet/worksheet.rb', line 22

def name(value=nil)
  value.nil? ? @name : @name = value.to_s
end

#row(row_obj) ⇒ Object

Osheet only stores the latest row in memory for reference memory bloat would be unmanageable in large spreadsheets if all rows were stored



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

def row(row_obj)
  @rows.pop
  @rows << row_obj
end