Method: String#indefinitize

Defined in:
lib/jinx/helpers/inflector.rb

#indefinitizeString

Returns this String with a leading indefinite article.

Examples:

"rose".indefinitize #=> "a rose"
"eagle".indefinitize #=> "an eagle"

Returns:

  • (String)

    this String with a leading indefinite article



25
26
27
28
# File 'lib/jinx/helpers/inflector.rb', line 25

def indefinitize
  article = self =~ /^[aeiou]/i ? 'an' : 'a'
  "#{article} #{self}"
end