module Csv2schema::Formats
Public Instance Methods
apply_formats()
click to toggle source
# File lib/csv2schema/formats.rb, line 4 def apply_formats @column_headers.each_with_index { |(k,v),i| @column_headers[k]['format'] = formats[i] } end
Private Instance Methods
formats()
click to toggle source
# File lib/csv2schema/formats.rb, line 10 def formats @formats ||= begin formats = @validator.instance_variable_get("@formats") formats.map do |formats| get_format(formats) end end end
get_format(candidates)
click to toggle source
# File lib/csv2schema/formats.rb, line 20 def get_format(candidates) total = candidates.values.reduce(:+) best = :string candidates.each do |k,v| best = k if v > (total * 0.8) end best end