Class: HtmlTable::TableRowBuilder
- Inherits:
-
Object
- Object
- HtmlTable::TableRowBuilder
- Defined in:
- lib/html_table_rails.rb
Instance Method Summary collapse
-
#initialize(object, template) ⇒ TableRowBuilder
constructor
A new instance of TableRowBuilder.
- #to_s ⇒ Object
- #value_with_localization(column_name, options) ⇒ Object
Constructor Details
#initialize(object, template) ⇒ TableRowBuilder
Returns a new instance of TableRowBuilder.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/html_table_rails.rb', line 24 def initialize(object, template) @object = object @columns = [] @html_columns = [] @template = template capture_method = (template.respond_to?(:is_haml?) && template.is_haml?) ? :capture_haml : :capture @output = template.send(capture_method) do yield(self) end end |
Instance Method Details
#to_s ⇒ Object
35 36 37 |
# File 'lib/html_table_rails.rb', line 35 def to_s "<tr>#{@output}</tr>" end |
#value_with_localization(column_name, options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/html_table_rails.rb', line 39 def value_with_localization column_name, if column_name && object.respond_to?(column_name) && ( object.send(column_name).is_a?(Time) || object.send(column_name).is_a?(Date) ) @template.l(object.send(column_name)) else value_without_localization(column_name, ) end end |