Module: Credentials::Inflector
Defined Under Namespace
Classes: Inflections
Instance Method Summary collapse
- #actorize(word) ⇒ Object
- #inflections ⇒ Object
- #pluralize(word) ⇒ Object
- #singularize(word) ⇒ Object
Instance Method Details
#actorize(word) ⇒ Object
74 75 76 77 78 |
# File 'lib/credentials/inflector.rb', line 74 def actorize(word) result = word.to_s.dup inflections.actors.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } unless result.empty? result end |
#inflections ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/credentials/inflector.rb', line 66 def inflections if block_given? yield Inflections.instance else Inflections.instance end end |
#pluralize(word) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/credentials/inflector.rb', line 81 def pluralize(word) result = word.to_s.dup if word.empty? || inflections.uncountables.include?(result.downcase) result else inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } result end end |
#singularize(word) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/credentials/inflector.rb', line 92 def singularize(word) result = word.to_s.dup if inflections.uncountables.include?(result.downcase) result else inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } result end end |