Method: Dentaku::Tokenizer#replace_aliases

Defined in:
lib/dentaku/tokenizer.rb

#replace_aliases(string) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/dentaku/tokenizer.rb', line 70

def replace_aliases(string)
  return string unless @aliases.any?

  string.gsub!(alias_regex) do |match|
    match_regex = /^#{Regexp.escape(match)}$/i

    @aliases.detect do |(_key, aliases)|
      !aliases.grep(match_regex).empty?
    end.first
  end

  string
end