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.
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 |
# File 'lib/simple_table/column.rb', line 5 def initialize(table, name, = {}) @table = table @name = name @value = .delete(:value) @options = .dup || {} @options[:class] ||= 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 |
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
13 14 15 |
# File 'lib/simple_table/column.rb', line 13 def content name.is_a?(Symbol) ? translate(name) : name end |
#translate(content) ⇒ Object
17 18 19 20 |
# File 'lib/simple_table/column.rb', line 17 def translate(content) scope = [SimpleTable.[:i18n_scope], @table.collection_name, :columns].compact I18n.t(content, :scope => scope) end |