Class: EasyTable::TableBuilder
- Inherits:
-
Object
- Object
- EasyTable::TableBuilder
- Includes:
- Components::Columns, Components::Spans
- Defined in:
- lib/easy_table/table_builder.rb
Defined Under Namespace
Modules: M
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(collection, template, options) ⇒ TableBuilder
constructor
A new instance of TableBuilder.
Methods included from Components::Spans
Methods included from Components::Columns
Constructor Details
#initialize(collection, template, options) ⇒ TableBuilder
Returns a new instance of TableBuilder.
23 24 25 26 27 28 |
# File 'lib/easy_table/table_builder.rb', line 23 def initialize(collection, template, ) @collection = collection @options, @tr_opts = () @template = template @node = Tree::TreeNode.new('root') end |
Instance Method Details
#build ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/easy_table/table_builder.rb', line 30 def build content_tag(:table, @options) do concat(content_tag(:thead) do thead end) concat(content_tag(:tbody) do @collection.each do |record| concat(content_tag(:tr, tr_opts(record)) do node.each_leaf do |leaf| leaf.content.td(record) end end) end end) end end |