Sha256: 3a23dcc2e34e905f81f53536f5679195f3e107fd05becd66b0e3eea519fdd7dd
Contents?: true
Size: 943 Bytes
Versions: 5
Compression:
Stored size: 943 Bytes
Contents
# A group of rows # # Can be of type: [:header, :footer, :body] module TableCreator class RowGroup include ActionView::Helpers::TagHelper attr_accessor :children, :parent, :options 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 def <<(child) @children << Row.new(child, self, :type => type) end def to_csv @children.map(&:to_csv).join("\n") end 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 end end
Version data entries
5 entries across 5 versions & 1 rubygems