class ApipieBindings::Inflector
Public Class Methods
inflections(locale = :en) { |instance| ... }
click to toggle source
# File lib/apipie_bindings/inflector.rb, line 92 def self.inflections(locale = :en) if block_given? yield ApipieBindings::Inflections.instance(locale) else ApipieBindings::Inflections.instance(locale) end end
pluralize(word, locale = :en)
click to toggle source
# File lib/apipie_bindings/inflector.rb, line 84 def self.pluralize(word, locale = :en) apply_inflections(word, inflections(locale).plurals) end
singularize(word, locale = :en)
click to toggle source
# File lib/apipie_bindings/inflector.rb, line 88 def self.singularize(word, locale = :en) apply_inflections(word, inflections(locale).singulars) end
Private Class Methods
apply_inflections(word, rules)
click to toggle source
# File lib/apipie_bindings/inflector.rb, line 102 def self.apply_inflections(word, rules) result = word.to_s.dup if word.empty? || inflections.uncountables.include?(result.downcase[/\b\w+\Z/]) result else rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) } result end end