Class: SimpleTable::Column
- Inherits:
-
Object
- Object
- SimpleTable::Column
- Defined in:
- lib/simple_table/column.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #attribute_name ⇒ Object
- #content ⇒ Object
-
#initialize(table, name, options = {}) ⇒ Column
constructor
A new instance of Column.
- #translate(content) ⇒ Object
Constructor Details
#initialize(table, name, options = {}) ⇒ Column
Returns a new instance of Column.
5 6 7 8 9 10 11 12 |
# File 'lib/simple_table/column.rb', line 5 def initialize(table, name, = {}) @table = table @name = name @value = .delete(:value) @options = .dup || {} @options[:class] ||= name @options[:id] ||= "#{name.to_s.downcase}_header" if name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/simple_table/column.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/simple_table/column.rb', line 3 def @options end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
3 4 5 |
# File 'lib/simple_table/column.rb', line 3 def table @table end |
Instance Method Details
#attribute_name ⇒ Object
22 23 24 |
# File 'lib/simple_table/column.rb', line 22 def attribute_name name.to_s.underscore end |
#content ⇒ Object
14 15 16 |
# File 'lib/simple_table/column.rb', line 14 def content name.is_a?(Symbol) ? translate(name) : name end |
#translate(content) ⇒ Object
18 19 20 |
# File 'lib/simple_table/column.rb', line 18 def translate(content) table.view.t(:".columns.#{name}", :default => '') end |