Class: Bumblebee::ColumnSet
- Inherits:
-
Object
- Object
- Bumblebee::ColumnSet
- Extended by:
- Forwardable
- Defined in:
- lib/bumblebee/column_set.rb
Overview
Maintains a list (dictionary) of columns where each header can only exist once. If columns with same header are re-added, then they are overwritten. This class also provides a factory interface through #add for adding columns
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #column(header, opts = {}) ⇒ Object
-
#initialize(columns = nil) ⇒ ColumnSet
constructor
A new instance of ColumnSet.
Constructor Details
#initialize(columns = nil) ⇒ ColumnSet
Returns a new instance of ColumnSet.
28 29 30 31 32 |
# File 'lib/bumblebee/column_set.rb', line 28 def initialize(columns = nil) @column_hash = {} add(columns) end |
Instance Method Details
#add(*args) ⇒ Object
42 43 44 45 46 |
# File 'lib/bumblebee/column_set.rb', line 42 def add(*args) args.flatten.compact.each { |arg| factory_add(arg) } self end |
#column(header, opts = {}) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/bumblebee/column_set.rb', line 34 def column(header, opts = {}) column = ::Bumblebee::Column.new(header, normalize_opts(opts)) column_hash[column.header] = column self end |