te_reo_maori 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 888493dde3753dab96b6a52cf6e923c3809fbf933cbc2660e1336573f7e3680f
4
- data.tar.gz: 89b86a9e0fefeede4cd44c5be9d13cc5347b37ff658708a86939cd1ebbd53b22
3
+ metadata.gz: 0c8a52e8d2878c16777d0c9dc0dd55f8e6bd06ab3cdba4d80b5a39848ef84668
4
+ data.tar.gz: d9e823fbc6fd89bfb00dd8ef07448224da8184eb026bb5e8d6c5cd17113f4eb6
5
5
  SHA512:
6
- metadata.gz: 3dedcefdb704f6c04d4782eb18b6455197dff7137c41a4ff5b23bc6dc52ce9d73fc28c56583b9cb0719a5f48d5839d89421ce9ea8691d66707950221c95bf58a
7
- data.tar.gz: 0214c81325760c026b87dd6af7f99f4f38c5207972ff059a023829b288fe8788ad43db076f2e3e41f639793282e97c38284c7b1d1432e4cc92e2e1d7f7d083aa
6
+ metadata.gz: e3347d474bcfdae117be822b4e7c767d698de58bf92e171db70822ab1e2cab34492c9a804494bc35c2424259e14ec124c0df9ec4b8569b615b27acc008fd37ed
7
+ data.tar.gz: af33af46aa99029683bd2e3cdc79322720a31072bb824d9962c21eb4e9b978d380bfccaede06894d1d4ba3db02f867429b8ad8c27e0118a5eeac1ab91bf78968
data/ChangeLog CHANGED
@@ -1,3 +1,5 @@
1
+ * 0.1.4 - Pronounce integers on inspection for better terminal experience
2
+ - Handle up to 999 and accent marks
1
3
  * 0.1.3 Bug fix. 'Whakahua' did not handle 'iwa' and numbers like toru tekau
2
4
  * 0.1.2 whakahua method to pronounce numbers
3
5
  * 0.1.1 Has docker image. Handle up to 99
@@ -18,8 +18,9 @@ puts 'The numbers are: '
18
18
  Tau.rarangi.each do |tau, whakamaoritanga|
19
19
  puts "#{tau}: #{whakamaoritanga}"
20
20
  end
21
+ puts 'If you type a number and press you will see Maori equivalent. Numbers > 10 must be wrapped in (). Greatest supported is 999'
21
22
  puts 'Example of bigger numbers. 12: "tekau ma rua". Add 23 + 33: "(rua tekau ma toru) + (toru tekau ma toru)"'
22
- puts 'To pronounce numbers one can use. "5.whakahua" or "whakahua((toru tekau ma tahi) + wha))"'
23
+ puts 'See integer form by calling "to_s", e.g., "((rua tekau ma toru) + (toru tekau ma toru)).to_s" '
23
24
  puts 'If you have any ideas on how this can be improved add issue to https://gitlab.com/samuel-garratt/te_reo_maori/-/issues'
24
25
 
25
26
  IRB.start(__FILE__)
@@ -13,7 +13,7 @@ module Tau
13
13
  # List numbers
14
14
  def self.rarangi
15
15
  {
16
- 1 => 'tahi', 2 => 'rua', 3 => 'toru', 4 => 'wha', 5 => 'rima', 6 => 'ono', 7 => 'waru',
16
+ 1 => 'tahi', 2 => 'rua', 3 => 'toru', 4 => 'whā', 5 => 'rima', 6 => 'ono', 7 => 'waru',
17
17
  8 => 'iwa', 9 => 'iwa', 10 => 'tekau'
18
18
  }
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TeReoMaori
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -2,24 +2,45 @@
2
2
 
3
3
  # Extension to Integer for Maori
4
4
  class Integer
5
+ def inspect
6
+ whakahua
7
+ end
8
+
9
+ # @param [Integer] upper_part Integer of number of 100s
10
+ # @param [String] lower_part Already translated part less than 100
11
+ def add_parts(upper_part, lower_part)
12
+ if upper_part == 0
13
+ lower_part
14
+ elsif upper_part == 1
15
+ "kotahi rau #{lower_part}"
16
+ else
17
+ "#{upper_part.whakahua} rau #{lower_part}"
18
+ end
19
+ end
20
+
5
21
  # Pronounce number
6
22
  def whakahua
7
- raise NotImplementedError, 'Pronounciation not implemented yet' if self > 99
23
+ raise NotImplementedError, "Amount of #{self} implemented yet" if self > 999 || self < 1
24
+ return 'kotahi rau' if self == 100
25
+
26
+ lower_part = self % 100
27
+ upper_part = self / 100
8
28
 
9
- last_digit = self % 10
29
+ last_digit = lower_part % 10
10
30
  last_digit_word = Tau.rarangi[last_digit]
11
31
 
12
- first_digit = (self / 10)
32
+ first_digit = (lower_part / 10)
13
33
  if first_digit.positive?
14
34
  if last_digit.zero?
15
- return 'tekau' if first_digit == 1
16
- return "#{Tau.rarangi[first_digit]} tekau"
35
+ return add_parts(upper_part, 'tekau') if first_digit == 1
36
+
37
+ return add_parts upper_part, "#{Tau.rarangi[first_digit]} tekau"
17
38
  end
18
39
 
19
- return "tekau ma #{last_digit_word}" if first_digit == 1
40
+ return add_parts upper_part, "tekau #{last_digit_word}" if first_digit == 1
20
41
 
21
- return "#{Tau.rarangi[first_digit]} tekau ma #{last_digit_word}"
42
+ return add_parts upper_part, "#{Tau.rarangi[first_digit]} tekau #{last_digit_word}"
22
43
  end
23
- last_digit_word
44
+ add_parts upper_part, last_digit_word
24
45
  end
25
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: te_reo_maori
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Tool to aid one to learn Maori and enable one to program in Maori.
14
14
  email: