Class: HtmlTable::TableRowBuilder
- Inherits:
-
Object
- Object
- HtmlTable::TableRowBuilder
- Defined in:
- lib/html_table/table_row_builder.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#html_columns ⇒ Object
Returns the value of attribute html_columns.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #column(column_name, *args) ⇒ Object
-
#initialize(object) {|_self| ... } ⇒ TableRowBuilder
constructor
A new instance of TableRowBuilder.
- #to_s ⇒ Object
- #value(column_name, options) ⇒ Object
Constructor Details
#initialize(object) {|_self| ... } ⇒ TableRowBuilder
Returns a new instance of TableRowBuilder.
4 5 6 7 8 9 |
# File 'lib/html_table/table_row_builder.rb', line 4 def initialize(object) @object = object @columns = [] @html_columns = [] yield(self) end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
2 3 4 |
# File 'lib/html_table/table_row_builder.rb', line 2 def columns @columns end |
#html_columns ⇒ Object
Returns the value of attribute html_columns.
2 3 4 |
# File 'lib/html_table/table_row_builder.rb', line 2 def html_columns @html_columns end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/html_table/table_row_builder.rb', line 3 def object @object end |
Instance Method Details
#column(column_name, *args) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/html_table/table_row_builder.rb', line 15 def column column_name, *args = args. columns << column_name html_columns << "<td>#{value(column_name, options)}</td>" html_columns.last end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/html_table/table_row_builder.rb', line 11 def to_s "<tr>#{html_columns}</tr>" end |
#value(column_name, options) ⇒ Object
22 23 24 |
# File 'lib/html_table/table_row_builder.rb', line 22 def value column_name, [:value] || column_name && object.send(column_name) end |