class TableCreator::RowGroup

Attributes

children[RW]
options[RW]
parent[RW]

Public Class Methods

new(row_group, parent, type = :body, options = nil) click to toggle source
# File lib/table_creator/row_group.rb, line 10
def initialize(row_group, parent, type = :body, options = nil)
  @parent = parent
  @children = []
  @options = options
  @type = type

  row_group.each do |row|
    if row.is_a? Hash
      @children << Row.new(row[:data], self, row.except(:data).merge(:type => type))
    else
      @children << Row.new(row, self, :type => type)
    end
  end
  self
end

Public Instance Methods

<<(child) click to toggle source
# File lib/table_creator/row_group.rb, line 26
def <<(child)
  @children << Row.new(child, self, :type => type)
end
to_csv() click to toggle source
# File lib/table_creator/row_group.rb, line 30
def to_csv
  @children.map(&:to_csv).join("\n")
end
to_html() click to toggle source
# File lib/table_creator/row_group.rb, line 34
def to_html
  tag = case @type; when :header; :thead; when :footer; :tfoot; else :tbody; end
  content_tag tag, children.map(&:to_html).join.html_safe, options
end