Class: EasyTable::Column
- Inherits:
-
Object
- Object
- EasyTable::Column
- Defined in:
- lib/easy_table/column.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value_block ⇒ Object
readonly
Returns the value of attribute value_block.
Instance Method Summary collapse
- #header(table, view) ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Column
constructor
A new instance of Column.
- #td_html ⇒ Object
- #th_html ⇒ Object
- #value(item, view) ⇒ Object
Constructor Details
#initialize(name, options = {}, &block) ⇒ Column
Returns a new instance of Column.
5 6 7 |
# File 'lib/easy_table/column.rb', line 5 def initialize(name, = {}, &block) @name, @options, @value_block = name, , block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/easy_table/column.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/easy_table/column.rb', line 3 def @options end |
#value_block ⇒ Object (readonly)
Returns the value of attribute value_block.
3 4 5 |
# File 'lib/easy_table/column.rb', line 3 def value_block @value_block end |
Instance Method Details
#header(table, view) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/easy_table/column.rb', line 9 def header(table, view) if [:header].present? [:header] elsif table.model_class table.model_class.human_attribute_name(name) end end |
#td_html ⇒ Object
21 22 23 |
# File 'lib/easy_table/column.rb', line 21 def td_html Config.td_html end |
#th_html ⇒ Object
17 18 19 |
# File 'lib/easy_table/column.rb', line 17 def th_html Config.th_html end |
#value(item, view) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/easy_table/column.rb', line 25 def value(item, view) if value_block view.capture(item, &value_block) else item.send(name) end end |