class Strings::Inflection::Noun

Public Instance Methods

+(other_word) click to toggle source

Combine this noun with another word

@param [String] other_word

the other word to combined with

@return [CombinedNoun]

@api public

# File lib/strings/inflection/noun.rb, line 65
def +(other_word)
  CombinedNoun.new([word, other_word])
end
plural() click to toggle source

Inflect a word to its plural form

@example

Strings::Inflection::Noun.new("error").plural
# => "errors"

@param [String] word

noun to inflect to plural form

@api public

# File lib/strings/inflection/noun.rb, line 50
def plural
  return word if word.to_s.empty?

  find_match(Inflection.configuration.plurals[:noun]) ||
    (uncountable? && word) || find_match(Nouns.plurals) || word
end
singular() click to toggle source

Inflect a word to its singular form

@example

Strings::Inflection::Noun.new("errors").singular
# => "error"

@param [String] word

the noun to inflect to singular form

@api public

# File lib/strings/inflection/noun.rb, line 33
def singular
  return word if word.to_s.empty?

  find_match(Inflection.configuration.singulars[:noun]) ||
    (uncountable? && word) || find_match(Nouns.singulars) || word
end
uncountable?() click to toggle source

Check if word is uncountable

@param [String] word

the word to check

@return [Boolean]

@api private

# File lib/strings/inflection/noun.rb, line 18
def uncountable?
  Inflection.configuration.uncountables[:noun].include?(word.downcase) ||
    Nouns.uncountable.include?(word.downcase)
end