module ToWords::Utils
Public Instance Methods
check_sign(num)
click to toggle source
# File lib/to_words/utils.rb, line 23 def check_sign(num) num < 0 ? [num.abs, "negative "] : [num, ""] end
higher_than_hundred(hundred, remaining, counter)
click to toggle source
# File lib/to_words/utils.rb, line 14 def higher_than_hundred(hundred, remaining, counter) century = UNDER_HUNDRED[hundred] if remaining != 0 return century + " Hundred " + UNDER_HUNDRED[remaining] if counter != 0 return century + " Hundred and " + UNDER_HUNDRED[remaining] end return century + " Hundred " if remaining == 0 end
numerical?(num)
click to toggle source
# File lib/to_words/utils.rb, line 27 def numerical?(num) Integer(num) rescue raise "A whole number is expected" end
result_below_one_thousand(num, counter)
click to toggle source
# File lib/to_words/utils.rb, line 7 def result_below_one_thousand(num, counter) hundred, remaining = num.divmod(100) return higher_than_hundred(hundred, remaining, counter) if hundred != 0 UNDER_HUNDRED[remaining] if hundred == 0 && remaining != 0 end