Class: Ods::Sheet
- Inherits:
-
Object
- Object
- Ods::Sheet
- Defined in:
- lib/ods.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #[](row, col) ⇒ Object
- #column ⇒ Object
-
#initialize(content) ⇒ Sheet
constructor
A new instance of Sheet.
- #name ⇒ Object
- #name=(name) ⇒ Object
- #rows ⇒ Object
Constructor Details
#initialize(content) ⇒ Sheet
Returns a new instance of Sheet.
97 98 99 |
# File 'lib/ods.rb', line 97 def initialize(content) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
96 97 98 |
# File 'lib/ods.rb', line 96 def content @content end |
Instance Method Details
#[](row, col) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ods.rb', line 109 def [](row, col) (row - rows.length).times do rows.push(Row.new(@content.add_element('table:table-row', 'table:style-name' => 'ro1'), rows.length+1)) end row = rows[row-1] col = ('A'..col.to_s).to_a.index(col.to_s) cols = row.cols (col - cols.length + 1).times do no = (cols.last) ? cols.last.no.to_s.succ : 'A' cols.push(Cell.new(row.add_element('table:table-cell', 'office:value-type' => 'string'), no)) end cols[col] end |
#column ⇒ Object
133 134 135 |
# File 'lib/ods.rb', line 133 def column Column.new(@content.xpath('table:table-column').first) end |
#name ⇒ Object
101 102 103 |
# File 'lib/ods.rb', line 101 def name @content.attribute('name').to_s end |
#name=(name) ⇒ Object
105 106 107 |
# File 'lib/ods.rb', line 105 def name=(name) @content.set_attribute('table:name', name) end |