EXPERIAN_LIB_DIR = File.dirname(__FILE__) Dir["#{EXPERIAN_LIB_DIR}/element_numbers/*.rb"].each { |f| require(f) } module Experian class DataDictionary def self.lookup(column, key) column = column.to_s.downcase.gsub(/\s+/, '') self.send("en_#{column}", key.to_s.strip) end def self.column_name(column) column = column.to_s.downcase.gsub(/\s+/, '') self.send("en_#{column}_column_name") end def self.description(column) column = column.to_s.downcase.gsub(/\s+/, '') self.send("en_#{column}_description") end def self.method_missing(method, *args, &block) method_parts = method.to_s.split('_') if (2..3) === method_parts.size and method_parts[0] == 'en' column = method_parts[1] if /^[0-9]{1,3}$/ =~ column column = "%04d" % column new_method = method_parts.size == 3 ? "en_#{column}_description".to_sym : "en_#{column}".to_sym elsif /[a-z]$/ =~ column letters = column.match(/[a-z]+$/)[0] column = "%04d" % column.to_i new_method = method_parts.size == 3 ? "en_#{column}#{letters}_description".to_sym : "en_#{column}#{letters}".to_sym end if self.methods.include?(new_method) return self.send(new_method, *args, &block) else super(new_method, *args, &block) end else super(method, *args, &block) end end end end