Class: Spreadsheetkit::Row
- Inherits:
-
Object
- Object
- Spreadsheetkit::Row
- Defined in:
- lib/spreadsheetkit/row.rb
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#merge ⇒ Object
readonly
Returns the value of attribute merge.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
-
#tr ⇒ Object
readonly
Returns the value of attribute tr.
Instance Method Summary collapse
-
#initialize(tr) ⇒ Row
constructor
A new instance of Row.
- #merge? ⇒ Boolean
- #render(row) ⇒ Object
Constructor Details
#initialize(tr) ⇒ Row
Returns a new instance of Row.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/spreadsheetkit/row.rb', line 6 def initialize(tr) @tr = tr @format = Spreadsheetkit::Format.new(@tr) @cells = [] @tr.css("td, th").each do|td| cell = Spreadsheetkit::Cell.new(td) @merge = true if cell.merge? @cells << cell end end |
Instance Attribute Details
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
4 5 6 |
# File 'lib/spreadsheetkit/row.rb', line 4 def cells @cells end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
4 5 6 |
# File 'lib/spreadsheetkit/row.rb', line 4 def format @format end |
#merge ⇒ Object (readonly)
Returns the value of attribute merge.
4 5 6 |
# File 'lib/spreadsheetkit/row.rb', line 4 def merge @merge end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
4 5 6 |
# File 'lib/spreadsheetkit/row.rb', line 4 def row @row end |
#tr ⇒ Object (readonly)
Returns the value of attribute tr.
4 5 6 |
# File 'lib/spreadsheetkit/row.rb', line 4 def tr @tr end |
Instance Method Details
#merge? ⇒ Boolean
18 19 20 |
# File 'lib/spreadsheetkit/row.rb', line 18 def merge? merge end |
#render(row) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/spreadsheetkit/row.rb', line 22 def render(row) @row = row apply_style @cells.each do |cell| cell_x = cell_x(cell) if merge? cell_x.upto(cell_x + cell.additional_columns) do |i| row.set_format(i, cell.format.style) end else row.set_format(cell_x, cell.format.style) end row[cell_x] = cell.content end end |