Class: WizRtf::Table
- Inherits:
-
Object
- Object
- WizRtf::Table
- Defined in:
- lib/wiz_rtf/table.rb
Constant Summary collapse
- DEFAULT_COLUMN_WIDTH =
40
Instance Attribute Summary collapse
-
#column_widths ⇒ Object
Returns the value of attribute column_widths.
-
#row_spans ⇒ Object
Returns the value of attribute row_spans.
Instance Method Summary collapse
- #add_row(cells = []) ⇒ Object
-
#initialize(rows = [], options = {}, &block) ⇒ Table
constructor
A new instance of Table.
- #render(io) ⇒ Object
Constructor Details
#initialize(rows = [], options = {}, &block) ⇒ Table
Returns a new instance of Table.
12 13 14 15 16 17 18 19 20 |
# File 'lib/wiz_rtf/table.rb', line 12 def initialize(rows = [], = {}, &block) @rows = [] @row_spans = {} @column_widths = [:column_widths] || DEFAULT_COLUMN_WIDTH rows.each_index do |index| add_row rows[index] end block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given? end |
Instance Attribute Details
#column_widths ⇒ Object
Returns the value of attribute column_widths.
10 11 12 |
# File 'lib/wiz_rtf/table.rb', line 10 def column_widths @column_widths end |
#row_spans ⇒ Object
Returns the value of attribute row_spans.
10 11 12 |
# File 'lib/wiz_rtf/table.rb', line 10 def row_spans @row_spans end |
Instance Method Details
#add_row(cells = []) ⇒ Object
22 23 24 |
# File 'lib/wiz_rtf/table.rb', line 22 def add_row(cells = []) @rows << WizRtf::Row.new(self, cells) end |
#render(io) ⇒ Object
26 27 28 29 30 |
# File 'lib/wiz_rtf/table.rb', line 26 def render(io) @rows.each do |row| row.render(io) end end |