c12-commons 0.0.1.beta4 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/c12-commons/ka.rb +10 -6
- data/lib/c12-commons/version.rb +1 -1
- data/spec/c12-commons/number_spec.rb +7 -3
- metadata +13 -13
data/lib/c12-commons/ka.rb
CHANGED
@@ -45,7 +45,7 @@ module C12
|
|
45
45
|
number_with_precision(number, :precision => opts[:precision] || 2, :delimiter => ' ', :separator => ',')
|
46
46
|
end
|
47
47
|
|
48
|
-
# Tokenize
|
48
|
+
# Tokenize number (in georgian).
|
49
49
|
#
|
50
50
|
# Example usage:
|
51
51
|
#
|
@@ -53,13 +53,17 @@ module C12
|
|
53
53
|
# C12::KA::tokenize(2) => 'ორი'
|
54
54
|
#
|
55
55
|
# The maximum value for the argument is the value <code>999,999,999,999</code>.
|
56
|
-
def self.tokenize(num)
|
56
|
+
def self.tokenize(num, opts = {})
|
57
57
|
num_ge_0 = nvl(num, 0).abs
|
58
|
-
if num
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
if num.instance_of? Fixnum
|
59
|
+
token = tokenize_int_ge_0(num_ge_0)
|
60
|
+
elsif num.instance_of? Float
|
61
|
+
int_part = num_ge_0.floor
|
62
|
+
dec_part = ((num_ge_0 - int_part) * 100).round
|
63
|
+
token = [tokenize_int_ge_0(num_ge_0.floor), opts[:currency], dec_part, opts[:currency_minor]].compact.join(' ')
|
62
64
|
end
|
65
|
+
token = "მინუს #{token}" if num < 0
|
66
|
+
token
|
63
67
|
end
|
64
68
|
|
65
69
|
private
|
data/lib/c12-commons/version.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
def test_number_tokenizer(num, expected_token)
|
5
|
+
def test_number_tokenizer(num, expected_token, opts = {})
|
6
6
|
describe "#{num} is" do
|
7
|
-
specify(expected_token) { C12::KA::tokenize(num).should == expected_token }
|
7
|
+
specify(expected_token) { C12::KA::tokenize(num, opts).should == expected_token }
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -13,4 +13,8 @@ test_number_tokenizer(-1, 'მინუს ერთი')
|
|
13
13
|
test_number_tokenizer(0, 'ნული')
|
14
14
|
test_number_tokenizer(1, 'ერთი')
|
15
15
|
test_number_tokenizer(999, 'ცხრაას ოთხმოცდა ცხრამეტი')
|
16
|
-
test_number_tokenizer(-9999, 'მინუს ცხრა ათას ცხრაას ოთხმოცდა ცხრამეტი')
|
16
|
+
test_number_tokenizer(-9999, 'მინუს ცხრა ათას ცხრაას ოთხმოცდა ცხრამეტი')
|
17
|
+
|
18
|
+
# currency
|
19
|
+
test_number_tokenizer(10.20, 'ათი ლარი 20 თეთრი', :currency => 'ლარი', :currency_minor => 'თეთრი')
|
20
|
+
test_number_tokenizer(390.20, 'სამას ოთხმოცდა ათი ლარი 20 თეთრი', :currency => 'ლარი', :currency_minor => 'თეთრი')
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c12-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dimitri Kurashvili
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70316684746560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70316684746560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simplecov
|
27
|
-
requirement: &
|
27
|
+
requirement: &70316684675880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70316684675880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: actionpack
|
38
|
-
requirement: &
|
38
|
+
requirement: &70316680599740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70316680599740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: prawn
|
49
|
-
requirement: &
|
49
|
+
requirement: &70316680351380 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0.12'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70316680351380
|
58
58
|
description: Simple functionality used in my projects
|
59
59
|
email:
|
60
60
|
- dimitri@c12.ge
|
@@ -98,9 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
101
|
-
- - ! '
|
101
|
+
- - ! '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project: c12-commons
|
106
106
|
rubygems_version: 1.8.15
|