number_read_out 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/Gemfile +1 -1
- data/README.md +8 -8
- data/lib/number_read_out.rb +18 -16
- data/lib/number_read_out/version.rb +1 -1
- data/number_read_out.gemspec +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aadcd8ef8da0e7c948f3ae6b843e1eb619b232d7
|
4
|
+
data.tar.gz: b0cfeaf9fd6009cfa9e6782dd8d9afb188f638ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 261c9ebc3abaff16c3deea3b35c27e48d5f968e7b2bb60b54704db9e993715b97449849481a9b2e144c40b62b360cabeb8ff106147014be37fd496eeb23e9775
|
7
|
+
data.tar.gz: d36085543f463f4fc84da0e4c105269a4fdce8540a897365902e0fce48b968a3b45fcb01bc82bae844cf90993d39481184548a3ee56336dc398ca09ec1d61574
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -47,14 +47,14 @@ NINETY-NINE EUROCENTS
|
|
47
47
|
|
48
48
|
or in Geek drachmas:
|
49
49
|
|
50
|
-
ΕΝΝΙΑΚΟΣΙΑ
|
51
|
-
ΕΝΝΙΑΚΟΣΙΑ
|
52
|
-
ΕΝΝΙΑΚΟΣΙΑ
|
53
|
-
ΕΝΝΙΑΚΟΣΙΑ
|
54
|
-
ΕΝΝΙΑΚΟΣΙEΣ
|
55
|
-
ΕΝΝΙΑΚΟΣΙEΣ
|
50
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΤΕΤΡΑΚΙΣΕΚΑΤΟΜΥΡΙΑ
|
51
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΤΡΙΣΕΚΑΤΟΜΥΡΙΑ
|
52
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΔΙΣΕΚΑΤΟΜΥΡΙΑ
|
53
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΕΚΑΤΟΜΥΡΙΑ
|
54
|
+
ΕΝΝΙΑΚΟΣΙEΣ ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΧΙΛΙΑΔΕΣ
|
55
|
+
ΕΝΝΙΑΚΟΣΙEΣ ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΔΡΑΧΜΕΣ
|
56
56
|
ΚΑΙ
|
57
|
-
|
57
|
+
ΕΝΕΝΗΝΤΑ ΕΝΝΕΑ ΛΕΠΤΑ
|
58
58
|
|
59
59
|
|
60
60
|
### Caveats
|
@@ -69,7 +69,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
69
69
|
|
70
70
|
## Contributing
|
71
71
|
|
72
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mpantel/number_read_out. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
73
73
|
|
74
74
|
|
75
75
|
## License
|
data/lib/number_read_out.rb
CHANGED
@@ -13,11 +13,11 @@ module NumberReadOut
|
|
13
13
|
units_singular: [ 'THOUSAND', 'THOUSAND', 'MILLION', 'BILLION', 'TRILLION', 'QUADRILLION'],
|
14
14
|
units_plural: [ 'THOUSAND', 'THOUSAND', 'MILLION', 'BILLION', 'TRILLION', 'QUADRILLION']
|
15
15
|
},
|
16
|
-
gr: {male: {hundreds: ['
|
16
|
+
gr: {male: {hundreds: ['ΕΚΑΤΟΝ', 'ΕΚΑΤΟ', 'ΔΙΑΚΟΣΙA', 'ΤΡΙΑΚΟΣΙΑ', 'ΤΕΤΡΑΚΟΣΙΑ', 'ΠΕΝΤΑΚΟΣΙΑ', 'ΕΞΑΚΟΣΙΑ', 'ΕΠΤΑΚΟΣΙΑ', 'ΟΚΤΑΚΟΣΙΑ', 'ΕΝΝΙΑΚΟΣΙΑ'],
|
17
17
|
dozens: ['', 'ΔΕΚΑ', 'ΕΙΚΟΣΙ', 'ΤΡΙΑΝΤΑ', 'ΣΑΡΑΝΤΑ', 'ΠΕΝΗΝΤΑ', 'ΕΞΗΝΤΑ', 'ΕΒΔΟΜΗΝΤΑ', 'ΟΓΔΟΝΤΑ', 'ΕΝΕΝΗΝΤΑ','ΔΕΚΑ', 'ΕΝΤΕΚΑ', 'ΔΩΔΕΚΑ', 'ΔΕΚΑΤΡΙΑ', 'ΔΕΚΑΤΕΣΣΕΡΑ', 'ΔΕΚΑΠΕΝΤΕ', 'ΔΕΚΑΕΞΙ', 'ΔΕΚΑΕΠΤΑ', 'ΔΕΚΑΟΚΤΩ', 'ΔΕΚΑΕΝΝΕΑ'],
|
18
18
|
monads: ['', 'ΕΝΑ', 'ΔΥΟ', 'ΤΡΙΑ', 'ΤΕΣΣΕΡΑ', 'ΠΕΝΤΕ', 'ΕΞΙ', 'ΕΠΤΑ', 'ΟΚΤΩ', 'ΕΝΝΕΑ'],
|
19
19
|
},
|
20
|
-
female: {hundreds: ['
|
20
|
+
female: {hundreds: ['ΕΚΑΤΟΝ', 'ΕΚΑΤΟ', 'ΔΙΑΚΟΣΙEΣ', 'ΤΡΙΑΚΟΣΙEΣ', 'ΤΕΤΡΑΚΟΣΙEΣ', 'ΠΕΝΤΑΚΟΣΙEΣ', 'ΕΞΑΚΟΣΙEΣ', 'ΕΠΤΑΚΟΣΙEΣ', 'ΟΚΤΑΚΟΣΙEΣ', 'ΕΝΝΙΑΚΟΣΙEΣ'],
|
21
21
|
dozens: ['', 'ΔΕΚΑ', 'ΕΙΚΟΣΙ', 'ΤΡΙΑΝΤΑ', 'ΣΑΡΑΝΤΑ', 'ΠΕΝΗΝΤΑ', 'ΕΞΗΝΤΑ', 'ΕΒΔΟΜΗΝΤΑ', 'ΟΓΔΟΝΤΑ', 'ΕΝΕΝΗΝΤΑ','ΔΕΚΑ', 'ΕΝΤΕΚΑ', 'ΔΩΔΕΚΑ', 'ΔΕΚΑΤΡΕΙΣ', 'ΔΕΚΑΤΕΣΣΕΡΙΣ', 'ΔΕΚΑΠEΝΤΕ', 'ΔΕΚΑΕΞΙ', 'ΔΕΚΑΕΠΤΑ', 'ΔΕΚΑΟΚΤΩ', 'ΔΕΚΑΕΝΝΕΑ'],
|
22
22
|
monads: ['', 'ΜΙΑ', 'ΔΥΟ', 'ΤΡΕΙΣ', 'ΤΕΣΣΕΡΙΣ', 'ΠΕΝΤΕ', 'ΕΞΙ', 'ΕΠΤΑ', 'ΟΚΤΩ', 'ΕΝΝΕΑ'],
|
23
23
|
},
|
@@ -27,7 +27,7 @@ module NumberReadOut
|
|
27
27
|
}
|
28
28
|
|
29
29
|
SpokenCurrencies = {en: {euro: ['EURO','EUROCENTS','EUROCENTS', 'AND','-'],drachmas:['DRACHMAS','CENTS','CENTS','AND','-']},
|
30
|
-
gr: {euro: ['ΕΥΡΩ','ΕΥΡΩΛΕΠΤΟ','ΕΥΡΩΛΕΠΤΑ', 'ΚΑΙ',''],drachmas:['ΔΡΑΧΜΕΣ','ΛΕΠΤΟ','ΛΕΠΤΑ', 'ΚΑΙ','']}}
|
30
|
+
gr: {euro: ['ΕΥΡΩ','ΕΥΡΩΛΕΠΤΟ','ΕΥΡΩΛΕΠΤΑ', 'ΚΑΙ',' '],drachmas:['ΔΡΑΧΜΕΣ','ΛΕΠΤΟ','ΛΕΠΤΑ', 'ΚΑΙ',' ']}}
|
31
31
|
|
32
32
|
PartOfNumber = [:hundreds, :thousands, :millions, :billions, :trillions, :quadrillions]
|
33
33
|
|
@@ -60,41 +60,43 @@ module NumberReadOut
|
|
60
60
|
hundreds, teens = triplet.divmod 100
|
61
61
|
dozens, monads = teens.divmod 10
|
62
62
|
|
63
|
-
genus = (([:hundreds, :thousands].include? part_of_number) and currency != :euro) ? :female : :male
|
63
|
+
genus = ((([:hundreds, :thousands].include? part_of_number) and currency != :euro ) or (([3,4].include? monads or dozens>0 or hundreds >0) and part_of_number == :thousands ) ) ? :female : :male
|
64
64
|
|
65
65
|
textual = ''
|
66
66
|
|
67
67
|
if hundreds != 0
|
68
|
-
hundreds_corrector = (teens != 0
|
68
|
+
hundreds_corrector = (teens != 0 and hundreds==1 ) ? 1 : 0
|
69
69
|
textual += SpokenNumbers[lang][genus][:hundreds][hundreds - hundreds_corrector ]
|
70
|
-
|
71
|
-
textual += ' '
|
72
|
-
|
73
|
-
|
70
|
+
|
71
|
+
textual += ' ' + SpokenCurrencies[:en][:euro][3] if lang == :en and teens >0
|
72
|
+
textual += ' ' if teens > 0 or part_of_number != :hundreds
|
73
|
+
|
74
74
|
end
|
75
75
|
|
76
76
|
if teens != 0
|
77
77
|
if teens >10 and teens < 20
|
78
78
|
textual += SpokenNumbers[lang][genus][:dozens][teens]
|
79
|
+
textual += ' ' if part_of_number != :hundreds
|
79
80
|
else
|
80
81
|
textual += SpokenNumbers[lang][genus][:dozens][dozens]
|
82
|
+
include_number_one = !(lang == :gr and part_of_number==:thousands and teens==1 and hundreds==0)
|
81
83
|
if monads != 0
|
82
84
|
textual +=SpokenCurrencies[lang][currency][4] if dozens >1
|
83
|
-
|
84
|
-
textual +=
|
85
|
-
else
|
86
|
-
textual += ' ' unless part_of_number == :hundreds
|
85
|
+
|
86
|
+
textual += SpokenNumbers[lang][genus][:monads][monads] if include_number_one
|
87
87
|
end
|
88
|
+
textual += ' ' if (part_of_number != :hundreds) and (include_number_one)
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
units = ((hundreds == 1 or monads==1) and dozens==0) ? :units_singular : :units_plural
|
92
|
-
|
93
92
|
if part_of_number != :hundreds
|
93
|
+
|
94
|
+
units = ((hundreds == 1 or monads==1) and dozens==0 and not (part_of_number == :thousands and triplet > 1 )) ? :units_singular : :units_plural
|
95
|
+
|
94
96
|
thousands_corrector = (units == :units_singular && genus == :female) ? 1 : 0
|
95
97
|
textual += SpokenNumbers[lang][units][PartOfNumber.index(part_of_number) - thousands_corrector]
|
96
98
|
end
|
97
|
-
textual += ' '
|
99
|
+
textual += ' '
|
98
100
|
textual
|
99
101
|
|
100
102
|
end
|
data/number_read_out.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
#if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata['allowed_push_host'] = "
|
20
|
+
# spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
21
|
#else
|
22
22
|
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
23
|
#end
|
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.12"
|
31
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
32
|
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
#spec.add_development_dependency "tiny_tds", "~> 1.0"
|
33
34
|
end
|