Class: BootstrapTableHelper::Row
- Inherits:
-
Object
- Object
- BootstrapTableHelper::Row
- Defined in:
- app/helpers/bootstrap_table_helper.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#options ⇒ Object
Returns the value of attribute options.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #column(options = {}, &block) ⇒ Object
-
#initialize(template, options = {}, &block) ⇒ Row
constructor
A new instance of Row.
- #to_s ⇒ Object
Constructor Details
#initialize(template, options = {}, &block) ⇒ Row
Returns a new instance of Row.
10 11 12 13 14 15 |
# File 'app/helpers/bootstrap_table_helper.rb', line 10 def initialize(template, ={}, &block) self.template = template self. = self.columns = [] block.call(self) end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
8 9 10 |
# File 'app/helpers/bootstrap_table_helper.rb', line 8 def columns @columns end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'app/helpers/bootstrap_table_helper.rb', line 8 def @options end |
#template ⇒ Object
Returns the value of attribute template.
8 9 10 |
# File 'app/helpers/bootstrap_table_helper.rb', line 8 def template @template end |
Instance Method Details
#column(options = {}, &block) ⇒ Object
17 18 19 |
# File 'app/helpers/bootstrap_table_helper.rb', line 17 def column(={}, &block) columns << [, block] end |
#to_s ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/bootstrap_table_helper.rb', line 21 def to_s template.content_tag(:tr, nil, ) do tr_content = [] columns.each do |column| = column.first [:style] ||= '' [:style] << "text-align: #{[:align]||'left'};" tr_content << template.content_tag(:td, nil, .dup.delete_if { |k, v| k.to_s == 'align' }) do template.capture(&column.second) end end tr_content.join.html_safe end end |