module ToRupees
Constants
- INTEGER_KLASS
- VERSION
Public Instance Methods
to_rupees()
click to toggle source
# File lib/to_rupees.rb, line 13 def to_rupees num = numerical?(self) in_words = '' if num <= 100 in_words = UNDER_HUNDRED[num] else counter = 0 result = [] num, remaining = num.divmod(1000) temp_result = result_below_one_thousand(remaining, counter) result << temp_result + " " + DIVISIONS[counter] + " " if temp_result counter += 1 while num != 0 num, remaining = num.divmod(100) temp_result = result_below_one_thousand(remaining, counter) result << temp_result + " " + DIVISIONS[counter] + " " if temp_result counter += 1 end in_words = result.reverse.join(", ").rstrip end (in_words + " rupee#{numerical?(self) > 1 ? 's' : ''}").titleize end