Sha256: e5a6963601171f16983319afd4ce3b08c38ca872c259de184f8c4723890068ca
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require_relative 'comp_bitz' module LanguageCards class Comparator def initialize mapping_key, mapping, collection ## # @title should be a hash like {"Romaji"=>"Katakana"} # @mapping should be an array like [:k, :v] @mapped_as, @mapping = mapping[mapping_key].reduce @collection = collection end def mapped_as case @mapping.first when :k @mapped_as.keys else @mapped_as.values end end def given key, value CompBitz.new( display: choose_display(key, value), collection: @collection, expected: choose_expected(key, value), value: value, mapping: @mapping.first ) end def match? input, comp_bitz case comp_bitz.mapping when :k comp_bitz.value == comp_bitz.collection[input] when :v comp_bitz.value == input end end private def choose_display key, value case @mapping.last when :k key when :v value end end def choose_expected key, value case @mapping.first when :k key when :v value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
language_cards-0.0.1 | lib/language_cards/comparator.rb |