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(width, 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(width, options = {}, &block) ⇒ Object
17 18 19 20 21 22 |
# File 'app/helpers/bootstrap_table_helper.rb', line 17 def column(width, ={}, &block) width, = nil, width if width.is_a?(Hash) [:class] ||= '' [:class] << "span#{width}" if width && width.to_i < 12 && width.to_i > 0 columns << [, block] end |
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/bootstrap_table_helper.rb', line 24 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) if column.second end end tr_content.join.html_safe end end |