Class: SimpleTable::Row
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
Attributes inherited from Tag
Instance Method Summary collapse
- #cell(*contents) ⇒ Object
-
#initialize(parent, record = nil, options = {}, &block) ⇒ Row
constructor
A new instance of Row.
- #render(record = nil, options = {}) ⇒ Object
Methods inherited from Tag
#add_class, #collection_class, #collection_name, #head?, #table
Constructor Details
#initialize(parent, record = nil, options = {}, &block) ⇒ Row
Returns a new instance of Row.
8 9 10 11 12 13 |
# File 'lib/simple_table/row.rb', line 8 def initialize(parent, record = nil, = {}, &block) @parent = parent @options = @cells = [] @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/simple_table/row.rb', line 6 def block @block end |
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
6 7 8 |
# File 'lib/simple_table/row.rb', line 6 def cells @cells end |
Instance Method Details
#cell(*contents) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/simple_table/row.rb', line 15 def cell(*contents) = contents.last.is_a?(Hash) ? contents.pop : {} if parent.is_a?(Body) add_class!(, current_column_class) add_header!(, current_column_id) end contents.each do |content| cells << Cell.new(self, content, ) end end |
#render(record = nil, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/simple_table/row.rb', line 26 def render(record = nil, = {}) @options.merge!() build(record) if block super(cells.map(&:render)) end |