class Float

Public Instance Methods

to_rupees() click to toggle source
# File lib/to_rupees.rb, line 50
      def to_rupees
  in_words = []
  v = divmod 1
  in_words << v[0].to_i.to_rupees
  if v[1].to_f.nonzero?
    decimal_in_words = ToRupees::UnderHundred::UNDER_HUNDRED[("%.2f" % v[1].to_f).split('.').last.to_i] + " paisa"
    in_words = [in_words.last.to_s.gsub(' and ', ' ').split(' ').join(' ')] if in_words.size.nonzero?
    in_words << decimal_in_words
  end
  in_words.map(&:titleize).join(' and ')
end