Sha256: de23f692aea6257b3a38b6a244a0993c880bdbf841455f436050399b25705811
Contents?: true
Size: 947 Bytes
Versions: 8
Compression:
Stored size: 947 Bytes
Contents
module LanguageCards class Mappings def initialize mapping, collection=nil @collection = collection @mappings = {} mapping.each do |h| index = h.delete("index") begin a,b = h.reduce rescue LocalJumpError raise InvalidMapping end a = I18n.t "LanguageName.#{a}" b = I18n.t "LanguageName.#{b}" @mappings["#{a} => #{b}"] = { h => index } end end def select_mapping string Comparator.new string, self, @collection end def classes s=nil keys.map do |names| [s, names].compact.join(JOIN) end end def [] key @mappings[key] end def has_key? key @mappings.has_key? key end def keys @mappings.keys end class InvalidMapping < StandardError def initialize super(I18n.t 'Errors.InvalidMapping') end end end end
Version data entries
8 entries across 8 versions & 1 rubygems