Sha256: 4d029cbe504f372d009755f9161eb5dbb7f1ae5f68e910af93d14de78e3e1fb9
Contents?: true
Size: 994 Bytes
Versions: 5
Compression:
Stored size: 994 Bytes
Contents
module ActiveSupport module Inflector class Inflections attr_reader :gerunds def stems @stems ||= [] end def stem(rule, replacement) @uncountables.delete(rule) if rule.is_a?(String) @uncountables.delete(replacement) stems.insert(0, [rule, replacement]) end end def adjectivize(word) word.match(/y$/) ? word : stem(word) + 'y' end def doerize(word) stem(word) + 'er' end def gerundize(word) stem(word) + 'ing' end def participlize(word) stem(word) + 'ed' end def superlativize(word, options = {}) if options[:adjective] stem(word) + 'est' else word.gsub(/y$/, "i") + 'est' end end def stem(word) result = word.to_s.dup if word.empty? result else inflections.stems.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } result end end end end
Version data entries
5 entries across 5 versions & 1 rubygems