Class: TableSortable::Columns
- Inherits:
-
Object
- Object
- TableSortable::Columns
- Defined in:
- lib/table_sortable/columns.rb
Instance Method Summary collapse
- #add(col_name, *options) ⇒ Object
-
#initialize ⇒ Columns
constructor
A new instance of Columns.
- #sort(&sort_proc) ⇒ Object
- #sort_by(sort_key) ⇒ Object
Constructor Details
#initialize ⇒ Columns
Returns a new instance of Columns.
4 5 6 |
# File 'lib/table_sortable/columns.rb', line 4 def initialize @columns = [] end |
Instance Method Details
#add(col_name, *options) ⇒ Object
8 9 10 11 |
# File 'lib/table_sortable/columns.rb', line 8 def add(col_name, *) = . @columns << TableSortable::Column.new(col_name, ) end |
#sort(&sort_proc) ⇒ Object
21 22 23 |
# File 'lib/table_sortable/columns.rb', line 21 def sort(&sort_proc) @columns.sort(&sort_proc) end |
#sort_by(sort_key) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/table_sortable/columns.rb', line 13 def sort_by(sort_key) if sort_key sort_key.map{|c| @columns.find{|col| (c.is_a?(String) ? (col.label == c) : col.name == c)}} else @columns end end |