Sha256: dd3e7355944a862c61124df26083ed68434377d08c16d2d31c625eaf3fc32e3c

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

# Extension to Integer for Maori
class Integer
  # Pronounce number
  def whakahua
    raise NotImplementedError, 'Pronounciation not implemented yet' if self > 99

    last_digit = self % 10
    last_digit_word = Tau.rarangi[last_digit]

    first_digit = (self / 10)
    if first_digit.positive?
      if last_digit.zero?
        return 'tekau' if first_digit == 1
        return "#{Tau.rarangi[first_digit]} tekau"
      end

      return "tekau ma #{last_digit_word}" if first_digit == 1

      return "#{Tau.rarangi[first_digit]} tekau ma #{last_digit_word}"
    end
    last_digit_word
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
te_reo_maori-0.1.3 lib/te_reo_maori/whakahua.rb