Class: InCSV::Column

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, values) ⇒ Column

Returns a new instance of Column.



5
6
7
8
# File 'lib/incsv/column.rb', line 5

def initialize(name, values)
  @name = name
  @values = values
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/incsv/column.rb', line 10

def name
  @name
end

Instance Method Details

#typeObject



12
13
14
15
16
17
18
19
# File 'lib/incsv/column.rb', line 12

def type
  Types.constants.select do |column_type|
    column_type = Types.const_get(column_type)
    if values.all? { |value| value.nil? || column_type.new(value).match? }
      return column_type
    end
  end
end