Sha256: 4b9f941f5eb7690d45619065307cf3ddf537d3b36630d29ac498a97f22869700

Contents?: true

Size: 659 Bytes

Versions: 3

Compression:

Stored size: 659 Bytes

Contents

module Tableficate
  class Empty
    def initialize(table, *args, &block)
      @table = table

      if block_given?
        @attrs   = args.first || {}
        @content = block
      else
        @content = args[0]
        @attrs   = args[1] || {}
      end
    end

    def value
      if @content.is_a?(String)
        @content
      else
        output = @content.call
        if output.is_a?(ActionView::OutputBuffer)
          ''
        else
          output = output.html_safe if output.respond_to? :html_safe
          output
        end
      end
    end

    def attrs
      @attrs[:colspan] = @table.columns.length
      @attrs
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tableficate-0.3.2 lib/tableficate/empty.rb
tableficate-0.3.1 lib/tableficate/empty.rb
tableficate-0.3.0 lib/tableficate/empty.rb