Method: Cellar#initialize
- Defined in:
- lib/cellar.rb
#initialize(obj = nil, header: true, strict: true, warn: true, index: nil) ⇒ Cellar
Returns a new instance of Cellar.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cellar.rb', line 37 def initialize(obj=nil, header: true, strict: true, warn: true, index: nil) @fields = [] @values = [] @finder = {} @seeker = {} @warn = warn @index = index @widest = 0 if obj.is_a?(Array) if obj.first.is_a?(Array) self.fields = obj.shift if header @rows = obj unless obj.empty? elsif !obj.empty? header ? (self.fields = obj) : (@rows = obj) end end @strict = strict.nil? ? !@fields.empty? : !!strict end |