Sha256: 852a4aafb16550ee0d6c2679b0128a2da69ce5f2ea64bd0426819a07d4c2a32a
Contents?: true
Size: 529 Bytes
Versions: 1
Compression:
Stored size: 529 Bytes
Contents
module MapFields class Mapping def initialize(mapping, fields) @mapping = mapping @fields = fields @mapping = mapping.each_with_object({}){ |arr, hash| key = arr[0].to_i value = arr[1].to_i hash[key] = value hash[@fields[key]] = value hash[field_to_symbol(@fields[key])] = value } end def [](index) @mapping[index] end private def field_to_symbol(field) field.to_s.downcase.gsub(/[^a-z0-9]+/, '_').to_sym end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
map_fields-2.0.0.beta | lib/map_fields/mapping.rb |