Class: Strings::Inflection::Verb

Inherits:
Term
  • Object
show all
Defined in:
lib/strings/inflection/verb.rb

Instance Attribute Summary

Attributes inherited from Term

#word

Instance Method Summary collapse

Methods inherited from Term

[], #find_match, #initialize, #plural?, #singular?, #to_s

Constructor Details

This class inherits a constructor from Strings::Inflection::Term

Instance Method Details

#pluralString

Inflect a word to its plural form

Examples:

Strings::Inflection::Verb.new("goes").plural
# => "go"

Returns:

  • (String)

    the verb inflected to plural form



47
48
49
50
51
# File 'lib/strings/inflection/verb.rb', line 47

def plural
  return word if word.to_s.empty? || uninflected?

  find_match(Verbs.plurals) || word
end

#singularString

Inflect a word to its singular form

Examples:

Strings::Inflection::Verb.new("go").singular
# => "goes"

Returns:

  • (String)

    the verb inflected to singular form



31
32
33
34
35
# File 'lib/strings/inflection/verb.rb', line 31

def singular
  return word if word.to_s.empty? || uninflected?

  find_match(Verbs.singulars) || word
end

#uninflected?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if word is uninflected

Parameters:

  • word (String)

    the word to check

Returns:

  • (Boolean)


17
18
19
# File 'lib/strings/inflection/verb.rb', line 17

def uninflected?
  Verbs.uninflected.include?(word)
end