Sha256: 785b03922f7ef1cbc2ac81cded0e36310015df69a678f08d13ab97049ce4826c
Contents?: true
Size: 614 Bytes
Versions: 2
Compression:
Stored size: 614 Bytes
Contents
module Crosscounter module Expansion def self.expand(keywords, expansions) keywords.inject({}) do |hash, keyword| hash[keyword] = resolved(expansions, keyword) hash end end def self.replace(enumerable, replacements) enumerable.map do |object| replacements.inject({}) do |hash, replacement| hash[replacement.first] = replacement.last.call(object) hash end end end def self.resolved(expansions, keyword) value = expansions.fetch(keyword) value.respond_to?(:call) ? value.call : value end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
crosscounter-0.3.0 | lib/crosscounter/expansion.rb |
crosscounter-0.2.0 | lib/crosscounter/expansion.rb |