Sha256: 7517fcad111656fa1b40ea4a040f874be3550429f6cbabf934e421a228128e50
Contents?: true
Size: 942 Bytes
Versions: 1
Compression:
Stored size: 942 Bytes
Contents
module I15R module PatternMatchers class Base # def self.inherited(descendant) # descendant.methods(false).grep /^match/ do |matcher_method| # descendant.method(matcher_method).call # end # end def self.matches(&block) @@matchers ||= [] @@matchers.push(block) end def self.run(text, prefix) i18ned_text = text @@matchers.each do |matcher| m = matcher.call(text, prefix) unless m.nil? plain_row, i18ned_row = m yield plain_row, i18ned_row if block_given? i18ned_text.gsub!(plain_row, i18ned_row) end end i18ned_text end #TODO: use method_added to add to matchers so that # matchers do not have to be explicitly registered. def self.register_matcher(matcher_method) self.method(matcher_method).call end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i15r-0.3.0 | lib/i15r/pattern_matchers/base.rb |