Class: Tableficate::Empty

Inherits:
Object
  • Object
show all
Defined in:
lib/tableficate/empty.rb

Instance Method Summary collapse

Constructor Details

#initialize(table, *args, &block) ⇒ Empty

Returns a new instance of Empty.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/tableficate/empty.rb', line 3

def initialize(table, *args, &block)
  @table = table

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

Instance Method Details

#attrsObject



29
30
31
32
# File 'lib/tableficate/empty.rb', line 29

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

#valueObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tableficate/empty.rb', line 15

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