Sha256: 4add85736ceef0c159f77a0418c89583af9821b57ed0a754b4d370909e06a730

Contents?: true

Size: 519 Bytes

Versions: 5

Compression:

Stored size: 519 Bytes

Contents

module TableCreator
  class Row
    include ActionView::Helpers::TagHelper

    attr_accessor :cols, :parent, :options

    def initialize(row, parent, options = {})
      @parent = parent
      @options = options
      @cols  = []
      row.each do |col|
        @cols << Col.new(col, row, options[:type])
      end
      self
    end

    def to_csv
      cols.map(&:to_csv).flatten.join(',')
    end

    def to_html
      content_tag :tr, cols.map(&:to_html).join.html_safe, options.except(:type)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
table_creator-0.4.0 lib/table_creator/row.rb
table_creator-0.3.0 lib/table_creator/row.rb
table_creator-0.2.0 lib/table_creator/row.rb
table_creator-0.1.1 lib/table_creator/row.rb
table_creator-0.1.0 lib/table_creator/row.rb