Class: SimpleTable::Row

Inherits:
Tag
  • Object
show all
Defined in:
lib/simple_table/row.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, record = nil, options = {}) {|[self, record].compact| ... } ⇒ Row

Returns a new instance of Row.

Yields:

  • ([self, record].compact)


6
7
8
9
10
11
12
13
14
# File 'lib/simple_table/row.rb', line 6

def initialize(parent, record = nil, options = {}, &block)
  super(parent, options)

  @parent = parent
  @cells = []
  @block = block

  yield(*[self, record].compact) if block_given?
end

Instance Method Details

#cell(*contents) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/simple_table/row.rb', line 16

def cell(*contents)
  options = contents.last.is_a?(Hash) ? contents.pop : {}
  add_class!(options, current_column_class) if parent.is_a?(Body)
  contents.each do |content|
    @cells << Cell.new(self, content, options)
  end
end

#renderObject



24
25
26
# File 'lib/simple_table/row.rb', line 24

def render
  super(@cells.map(&:render))
end