Sha256: e31590d8ce302e19969058eb10acb3bad91c6b5d48848c00dd96d46c3c234682
Contents?: true
Size: 701 Bytes
Versions: 12
Compression:
Stored size: 701 Bytes
Contents
require_relative 'constants/fr' module Humanize class Fr def humanize(number) iteration = 0 parts = [] until number.zero? number, remainder = number.divmod(1000) unless remainder.zero? add_grouping(parts, iteration) parts << SUB_ONE_GROUPING[remainder] unless exactly_one_thousand?(remainder, parts) end iteration += 1 end parts end private def exactly_one_thousand?(remainder, parts) remainder == 1 && parts.last.to_s.strip == 'mille' end def add_grouping(parts, iteration) grouping = LOTS[iteration] return unless grouping parts << grouping end end end
Version data entries
12 entries across 12 versions & 1 rubygems