Class: PdfTempura::Document::Table
- Inherits:
-
Field::Base
- Object
- Field::Base
- PdfTempura::Document::Table
- Defined in:
- lib/pdf_tempura/document/table.rb
Defined Under Namespace
Classes: BoxedCharacterColumn, CheckboxColumn, Column, Spacer, TextColumn
Instance Attribute Summary collapse
-
#cell_padding ⇒ Object
Returns the value of attribute cell_padding.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#row_count ⇒ Object
Returns the value of attribute row_count.
-
#row_height ⇒ Object
Returns the value of attribute row_height.
Attributes inherited from Field::Base
Instance Method Summary collapse
- #boxed_character_column(name, options = {}, &block) ⇒ Object
- #checkbox_column(name, width, options = {}) ⇒ Object
- #fields_for(values, &block) ⇒ Object
- #height ⇒ Object
-
#initialize(name, coordinates, options = {}, &block) ⇒ Table
constructor
A new instance of Table.
- #space(width) ⇒ Object
- #text_column(name, width, options = {}) ⇒ Object
- #width ⇒ Object
Methods inherited from Field::Base
Methods included from Validation
Constructor Details
#initialize(name, coordinates, options = {}, &block) ⇒ Table
Returns a new instance of Table.
11 12 13 14 15 16 17 |
# File 'lib/pdf_tempura/document/table.rb', line 11 def initialize(name,coordinates, = {},&block) super name, coordinates, [0,0], @columns = [] instance_eval(&block) if block_given? end |
Instance Attribute Details
#cell_padding ⇒ Object
Returns the value of attribute cell_padding.
4 5 6 |
# File 'lib/pdf_tempura/document/table.rb', line 4 def cell_padding @cell_padding end |
#columns ⇒ Object
Returns the value of attribute columns.
4 5 6 |
# File 'lib/pdf_tempura/document/table.rb', line 4 def columns @columns end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/pdf_tempura/document/table.rb', line 4 def name @name end |
#padding ⇒ Object
Returns the value of attribute padding.
4 5 6 |
# File 'lib/pdf_tempura/document/table.rb', line 4 def padding @padding end |
#row_count ⇒ Object
Returns the value of attribute row_count.
4 5 6 |
# File 'lib/pdf_tempura/document/table.rb', line 4 def row_count @row_count end |
#row_height ⇒ Object
Returns the value of attribute row_height.
4 5 6 |
# File 'lib/pdf_tempura/document/table.rb', line 4 def row_height @row_height end |
Instance Method Details
#boxed_character_column(name, options = {}, &block) ⇒ Object
39 40 41 |
# File 'lib/pdf_tempura/document/table.rb', line 39 def boxed_character_column(name, = {}, &block) columns << Document::Table::BoxedCharacterColumn.new(name, row_height, @options.merge(), &block) end |
#checkbox_column(name, width, options = {}) ⇒ Object
35 36 37 |
# File 'lib/pdf_tempura/document/table.rb', line 35 def checkbox_column(name, width, = {}) columns << Document::Table::CheckboxColumn.new(name, width, row_height, @options.merge()) end |
#fields_for(values, &block) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/pdf_tempura/document/table.rb', line 47 def fields_for(values, &block) values.inject(self.y) do |y, value_hash| generate_columns(y, value_hash, &block) y - row_height end end |
#height ⇒ Object
23 24 25 |
# File 'lib/pdf_tempura/document/table.rb', line 23 def height @height ||= row_height * row_count end |
#space(width) ⇒ Object
43 44 45 |
# File 'lib/pdf_tempura/document/table.rb', line 43 def space(width) columns << Document::Table::Spacer.new(width, row_height) end |
#text_column(name, width, options = {}) ⇒ Object
31 32 33 |
# File 'lib/pdf_tempura/document/table.rb', line 31 def text_column(name, width, = {}) columns << Document::Table::TextColumn.new(name, width, row_height, @options.merge()) end |
#width ⇒ Object
19 20 21 |
# File 'lib/pdf_tempura/document/table.rb', line 19 def width table_width + padding_width end |