Sha256: e08e4b12ec5a57d952f2673533b90b4bb04d9054f3f933978efeca1fea703cca
Contents?: true
Size: 699 Bytes
Versions: 14
Compression:
Stored size: 699 Bytes
Contents
require_relative 'constants/az' module Humanize class Az 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 == 'min' end def add_grouping(parts, iteration) grouping = LOTS[iteration] return unless grouping parts << grouping end end end
Version data entries
14 entries across 14 versions & 1 rubygems