Sha256: 65dff98880996573f1c28f6a2cf85828899f99b3346d6ede398d0c638da64aff

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require_relative 'whakahua'

# Number in Maori
module Tau
  def whakahua(tau)
    raise "Class '#{tau.class}' not implmemented" unless tau.is_a? Integer

    tau.whakahua
  end

  # List numbers
  def self.rarangi
    {
      1 => 'tahi', 2 => 'rua', 3 => 'toru', 4 => 'whā', 5 => 'rima', 6 => 'ono', 7 => 'whitu',
      8 => 'waru', 9 => 'iwa', 10 => 'tekau'
    }
  end

  # Handles multiple digits
  def digit(tau, second_digit)
    return tau if second_digit.nil?

    ((tau - 1) * 10) + second_digit
  end

  # 1
  def tahi
    1
  end

  # 2
  def rua(second_digit = nil)
    digit(2, second_digit)
  end

  # 3
  def toru(second_digit = nil)
    digit(3, second_digit)
  end

  # 4
  def wha(second_digit = nil)
    digit(4, second_digit)
  end

  alias whā wha

  # 5
  def rima(second_digit = nil)
    digit(5, second_digit)
  end

  # 6
  def ono(second_digit = nil)
    digit(6, second_digit)
  end

  def whitu(second_digit = nil)
    digit(7, second_digit)
  end

  def waru(second_digit = nil)
    digit(8, second_digit)
  end

  def iwa(second_digit = nil)
    digit(9, second_digit)
  end

  # 10. Used to add groups of 10
  def tekau(extra_digit = nil)
    extra_digit ? 10 + extra_digit : 10
  end

  # Add extra digit
  def ma(extra_digit)
    extra_digit
  end

  alias mā ma
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
te_reo_maori-0.1.8 lib/te_reo_maori/tau.rb
te_reo_maori-0.1.7 lib/te_reo_maori/tau.rb