digit_delim 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/digit_delim.gemspec +3 -3
- data/lib/kannum.rb +21 -0
- data/test/test_kannum.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482a179eb70f97b84a6dad8dbf8cf0c33934a755
|
4
|
+
data.tar.gz: 101b6f1f99854030ee3d326d45fa33327bad73af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd60ff0d7b2b78d1014205d6d312638a7224dee1d2e8ee22b2d234b63d832ea05e3d5645c935de2f00d716554db5ed7b500e6755f313bc1f5a22ee8038df12e
|
7
|
+
data.tar.gz: 31fae4990d428e93995febfa6d20390f2b58fc9b5dbcf5f9e71d218262badbe0291d5ea1bdced022ac186e8f47accf37e0cd8a4545e190bf27d0a8770e474197
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/digit_delim.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: digit_delim 0.
|
5
|
+
# stub: digit_delim 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "digit_delim"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["YAMAMOTO, Masayuki"]
|
14
|
-
s.date = "2016-07
|
14
|
+
s.date = "2016-08-07"
|
15
15
|
s.description = "methods of num-string formatter, converter which extends String class"
|
16
16
|
s.email = "martin.route66.blues+github@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/kannum.rb
CHANGED
@@ -27,6 +27,9 @@ module KanNum
|
|
27
27
|
'7'=>7,
|
28
28
|
'8'=>8,
|
29
29
|
'9'=>9,
|
30
|
+
|
31
|
+
'−'=>'-', # 全角マイナス => '-'
|
32
|
+
'-'=>'-', # minus (dummy map)
|
30
33
|
}
|
31
34
|
|
32
35
|
N_数_ext = {
|
@@ -212,12 +215,20 @@ module KanNum
|
|
212
215
|
|
213
216
|
def self.str_to_num( str )
|
214
217
|
|
218
|
+
minus_f = false
|
219
|
+
if str =~ /^-/
|
220
|
+
str = str.gsub(/^-/, '')
|
221
|
+
minus_f = true
|
222
|
+
end
|
223
|
+
|
215
224
|
tmp = translate_phase0(str)
|
216
225
|
# $stderr.puts "result0: #{tmp}"
|
217
226
|
tmp = translate_phase1(tmp)
|
218
227
|
# $stderr.puts "result1: #{tmp}"
|
219
228
|
ret = translate_phase2(tmp)
|
220
229
|
|
230
|
+
ret *= -1 if minus_f
|
231
|
+
|
221
232
|
ret
|
222
233
|
end
|
223
234
|
|
@@ -265,11 +276,21 @@ module KanNum
|
|
265
276
|
|
266
277
|
def self.num_to_str( num )
|
267
278
|
|
279
|
+
minus_f = false
|
280
|
+
if num < 0
|
281
|
+
num *= -1
|
282
|
+
minus_f = true
|
283
|
+
end
|
284
|
+
|
268
285
|
tmp = convert_phase0(num)
|
269
286
|
# $stderr.puts "{#{__method__}}result0: #{tmp}"
|
270
287
|
ret = convert_phase1(tmp)
|
271
288
|
# $stderr.puts "result1: #{ret}"
|
272
289
|
|
290
|
+
if minus_f
|
291
|
+
ret = "-"+ret
|
292
|
+
end
|
293
|
+
|
273
294
|
ret
|
274
295
|
end
|
275
296
|
|
data/test/test_kannum.rb
CHANGED
@@ -56,6 +56,10 @@ class TestKanNum < Test::Unit::TestCase
|
|
56
56
|
exp = 1_3200
|
57
57
|
assert_equal( exp, ret )
|
58
58
|
|
59
|
+
ret = "-3億900万".str_to_num
|
60
|
+
exp = -3_0900_0000
|
61
|
+
assert_equal( exp, ret )
|
62
|
+
|
59
63
|
ret = @pattern_t1.str_to_num
|
60
64
|
exp = @pattern_n1
|
61
65
|
assert_equal( exp, ret )
|
@@ -133,6 +137,10 @@ class TestKanNum < Test::Unit::TestCase
|
|
133
137
|
exp = "1万3200"
|
134
138
|
assert_equal( exp, ret )
|
135
139
|
|
140
|
+
ret = -3_0900_0000.num_to_str
|
141
|
+
exp = "-3億900万"
|
142
|
+
assert_equal( exp, ret )
|
143
|
+
|
136
144
|
ret = @pattern_n1.num_to_str
|
137
145
|
exp = @pattern_t1
|
138
146
|
assert_equal( exp, ret )
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digit_delim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YAMAMOTO, Masayuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|