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 +4 -4
- data/README.md +2 -2
- data/lib/chinese_numerals/version.rb +1 -1
- data/lib/chinese_numerals.rb +1 -1
- data/spec/chinese_number_spec.rb +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c0390909dd344229b6cb2f2136213ff1fb55d49
|
4
|
+
data.tar.gz: f5c83024665d0d2c04519eb476d3a3c7b33e7c0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e454675c52fc8d54d9516fd88973a23fd3cdc879ff90f24d153d2808e3e0af13dd9b84ced5e728a29f04490eae4cf8b253d6a1739ee14f74eee6b4d63bdf12e4
|
7
|
+
data.tar.gz: 268cb2b703c7fcda17d13978647ef5ff24c906dcf0fa62eca6ef11a520b741a13dd6ccf64a8b2fc7638a021102c0bc3939800f7195c6d3cefaa8bcf114f8bdef
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ChineseNumerals
|
2
2
|
|
3
|
-
|
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
|
-
|
21
|
+
Check the `spec/chinese_numerals_spec.rb` to see the various outcomes.
|
22
22
|
|
23
23
|
## Contributing
|
24
24
|
|
data/lib/chinese_numerals.rb
CHANGED
@@ -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.
|
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
|