Class: SimpleTable::Cell

Inherits:
Tag
  • Object
show all
Defined in:
lib/simple_table/cell.rb

Instance Attribute Summary

Attributes inherited from Tag

#options, #parent

Instance Method Summary collapse

Methods inherited from Tag

#add_class, #collection_class, #collection_name, #head?, #table

Constructor Details

#initialize(parent, content = nil, options = {}) {|_self| ... } ⇒ Cell

Returns a new instance of Cell.

Yields:

  • (_self)

Yield Parameters:



5
6
7
8
9
10
# File 'lib/simple_table/cell.rb', line 5

def initialize(parent, content = nil, options = {})
  super(parent, options)
  @content = content
  options[:colspan] = table.columns.size if options[:colspan] == :all
  yield self if block_given?
end

Instance Method Details

#contentObject



12
13
14
# File 'lib/simple_table/cell.rb', line 12

def content
  table.view && @content.is_a?(Symbol) ? table.view.t(@content) : @content
end

#renderObject



16
17
18
# File 'lib/simple_table/cell.rb', line 16

def render
  super(content, !content.html_safe?)
end

#tag_nameObject



20
21
22
# File 'lib/simple_table/cell.rb', line 20

def tag_name
  options[:tag_name] || parent.head? ? :th : :td
end