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

Version Path
humanize-3.0.0 lib/humanize/locales/az.rb
humanize-2.5.1 lib/humanize/locales/az.rb
humanize-2.5.0 lib/humanize/locales/az.rb
humanize-2.4.3 lib/humanize/locales/az.rb
humanize-2.4.2 lib/humanize/locales/az.rb
humanize-2.4.1 lib/humanize/locales/az.rb
humanize-2.4.0 lib/humanize/locales/az.rb
humanize-2.3.0 lib/humanize/locales/az.rb
humanize-2.2.1 lib/humanize/locales/az.rb
humanize-2.2.0 lib/humanize/locales/az.rb
humanize-2.1.2 lib/humanize/locales/az.rb
humanize-2.1.1 lib/humanize/locales/az.rb
humanize-2.1.0 lib/humanize/locales/az.rb
humanize-2.0.0 lib/humanize/locales/az.rb