chinese_numerals 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 260251716921de8dc6ac8cb3ad1efbe658bd6ba4
4
- data.tar.gz: e738525fa63fa9014a0b6f923e7b37893cf9a854
3
+ metadata.gz: 3c0390909dd344229b6cb2f2136213ff1fb55d49
4
+ data.tar.gz: f5c83024665d0d2c04519eb476d3a3c7b33e7c0c
5
5
  SHA512:
6
- metadata.gz: 151e113d91624945b8fdeeefd1e5c20c3ef486a74e312fd8f305a59373656153bac192f4252d999e518f3625003d2d0c4b23bb69a006028c2f884d5a38b2f56b
7
- data.tar.gz: a9f639c46eb949ab57e30815bae41b25572c27dfd0e39e85361c1e70cf153ad9c468a9e3eb413765f8a508e8513dc0bbdffb26c761a2dff7e259d92254b7854a
6
+ metadata.gz: e454675c52fc8d54d9516fd88973a23fd3cdc879ff90f24d153d2808e3e0af13dd9b84ced5e728a29f04490eae4cf8b253d6a1739ee14f74eee6b4d63bdf12e4
7
+ data.tar.gz: 268cb2b703c7fcda17d13978647ef5ff24c906dcf0fa62eca6ef11a520b741a13dd6ccf64a8b2fc7638a021102c0bc3939800f7195c6d3cefaa8bcf114f8bdef
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ChineseNumerals
2
2
 
3
- TODO: Write a gem description
3
+ This simple monkey patching enables the conversion from Integer to Chinese Numerals easily. The single method `to_chinese(:simple => true, :decimal => false)` is the only thing you need to take care.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Check the `spec/chinese_numerals_spec.rb` to see the various outcomes.
22
22
 
23
23
  ## Contributing
24
24
 
@@ -1,3 +1,3 @@
1
1
  module ChineseNumerals
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- class Integer
3
+ Integer.class_eval do
4
4
  CHINESE_GROUPS = [ '', '萬', '億', '兆', '京', '陔' ]
5
5
 
6
6
  FORMAL_CHINESE_NUMBERS = %w{ 零 壹 貳 參 肆 伍 陸 柒 捌 玖 }
@@ -0,0 +1,41 @@
1
+ $VERBOSE = true
2
+ require 'minitest/autorun'
3
+ require 'minitest/spec'
4
+
5
+ require_relative '../lib/chinese_numerals.rb'
6
+
7
+ describe Integer do
8
+ it "maps each digit" do
9
+ 10000.to_chinese.must_equal("一零零零零")
10
+ end
11
+
12
+ it "maps each digit with formal Chinese digits" do
13
+ 10000.to_chinese(:simple => false).must_equal("壹零零零零")
14
+ end
15
+
16
+ it "emits zero in decimal mode" do
17
+ 0.to_chinese(:decimal => true).must_equal("零")
18
+ end
19
+
20
+ it "generates decimal notations in decimal mode" do
21
+ 12.to_chinese(:decimal => true).must_equal("一十二")
22
+ end
23
+
24
+ it "shortens middle zeros in decimal mode" do
25
+ 1002.to_chinese(:decimal => true).must_equal("一千零二")
26
+ end
27
+
28
+ it "omits the tail zero in decimal mode" do
29
+ 1200.to_chinese(:decimal => true).must_equal("一千二百")
30
+ end
31
+
32
+ it "omits all tail zeros in decimal mode" do
33
+ 10000000000.to_chinese(:decimal => true).must_equal("一百億")
34
+ end
35
+
36
+ it "knows output and omit zeros in decimal mode" do
37
+ 10000002000.to_chinese(:decimal => true).must_equal("一百億二千")
38
+ end
39
+
40
+ end
41
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chinese_numerals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fox Chao
@@ -67,6 +67,7 @@ files:
67
67
  - chinese_numerals.gemspec
68
68
  - lib/chinese_numerals.rb
69
69
  - lib/chinese_numerals/version.rb
70
+ - spec/chinese_number_spec.rb
70
71
  homepage: https://rubygems.org/gems/chinese_numerals
71
72
  licenses:
72
73
  - MIT
@@ -91,4 +92,5 @@ rubygems_version: 2.2.2
91
92
  signing_key:
92
93
  specification_version: 4
93
94
  summary: Convert integers to Chinese Numerals
94
- test_files: []
95
+ test_files:
96
+ - spec/chinese_number_spec.rb