module NumberWords

Constants

DAT
DATA_FILE
LARGE_NUMS
ORDINALS
WORDS

Public Instance Methods

change_last_word(text) click to toggle source
# File lib/modules/number_words.rb, line 17
def change_last_word(text)
  words = text.split(/(\W)/)
  last = words[words.size - 1]
  new_last = ordinal_word(last)
  words[words.size - 1] = new_last
  words.join
end
ordinal_word(word) click to toggle source
# File lib/modules/number_words.rb, line 25
def ordinal_word(word)
  ORDINALS[word] || word += 'th'
end
to_word_ordinal(num, options = {}) click to toggle source
# File lib/modules/number_words.rb, line 12
def to_word_ordinal(num, options = {})
  text = NumbersToWords.new(options).to_words(num)
  change_last_word(text)
end
to_words(num, options = {}) click to toggle source
# File lib/modules/number_words.rb, line 8
def to_words(num, options = {})
  NumbersToWords.new(options).to_words(num)
end