Sha256: 79f1100a4a5646fddf71969941850cfb2fd32ed1835afe08cb53cf834c479a22
Contents?: true
Size: 824 Bytes
Versions: 14
Compression:
Stored size: 824 Bytes
Contents
require_relative 'constants/de' module Humanize class De def humanize(number) iteration = 0 parts = [] use_and = false until number.zero? number, remainder = number.divmod(1000) unless remainder.zero? if iteration.zero? && remainder < 100 use_and = true else add_grouping(parts, use_and, iteration) end parts << SUB_ONE_GROUPING[remainder] end iteration += 1 end parts end private def conjunction(parts, use_and) return '' if parts.empty? || !use_and ' und' end def add_grouping(parts, use_and, iteration) grouping = LOTS[iteration] return unless grouping parts << "#{grouping}#{conjunction(parts, use_and)}" end end end
Version data entries
14 entries across 14 versions & 1 rubygems