Sha256: 655001f0155bf6cff8d3123e0cfdbd8262e9f822a23e108ea9c1f64d6655d7e8
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
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 order key # what was my intention in design here? self[key].values.flatten end def has_key? key @mappings.has_key? key end def keys @mappings.keys end def inspect @mappings.keys end class InvalidMapping < StandardError def initialize super(I18n.t 'Errors.InvalidMapping') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
language_cards-0.0.3 | lib/language_cards/mapping.rb |
language_cards-0.0.2 | lib/language_cards/mapping.rb |