class Tabular::ColumnMapper

Public Instance Methods

map(key) click to toggle source

Convert key to normalized symbol. Subclass for more complex mapping.

# File lib/tabular/column_mapper.rb, line 8
def map(key)
  return nil if is_blank?(key)

  symbolize key
end
symbolize(key) click to toggle source
# File lib/tabular/column_mapper.rb, line 14
def symbolize(key)
  key.to_s.strip.gsub(/::/, "/")
     .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
     .gsub(/([a-z\d])([A-Z])/, '\1_\2')
     .tr("-", "_")
     .gsub(/ +/, "_")
     .delete(";")
     .downcase
     .to_sym
rescue StandardError
  nil
end