Class: SimpleTable::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_table/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @table = table
  @name = name
  @value = options.delete(:value)
  @options = options.dup || {}
  @options[:class] ||= name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/simple_table/column.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/simple_table/column.rb', line 3

def options
  @options
end

Instance Method Details

#attribute_nameObject



22
23
24
# File 'lib/simple_table/column.rb', line 22

def attribute_name
  name.to_s.underscore
end

#contentObject



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.options[:i18n_scope], @table.collection_name, :columns].compact
  I18n.t(content, :scope => scope)
end