Sha256: 4f2f17c668b9f26b060a90fea050a92f853b5aefa10ebb5a9e6876d015cca30d

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 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 => 'waru',
      8 => 'iwa', 9 => 'iwa', 10 => 'tekau'
    }
  end

  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

  # 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
te_reo_maori-0.1.5 lib/te_reo_maori/tau.rb
te_reo_maori-0.1.4 lib/te_reo_maori/tau.rb