number_read_out 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +78 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/number_read_out/version.rb +3 -0
- data/lib/number_read_out.rb +132 -0
- data/number_read_out.gemspec +33 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 19a723c4c559e30427f29aa93167d371b87225a1
|
4
|
+
data.tar.gz: 98cac54ab9cdd736b1b34ced1a6a6c66b7329a75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 254d25bb30825309957592cb4101b1f39b9b42fb4e1875d4f71bd44e17ab190a9442c0e41280e8024b4d949a6ecb54e37b9d900b7d3c7e949642bbc0625165eb
|
7
|
+
data.tar.gz: e2d3251c828c1d098989b1c4e35b790cb9adbef157cd59d1d481d86557e4e2ab5039e6a31e3c7e49ff05f48dc56ced01f23f80e3b68e7da24a1fdde5a8b597d1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at mpantel@aegean.gr. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Michail Pantelelis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# NumberReadOut
|
2
|
+
|
3
|
+
This is a utility gem to convert numbers or currencies, to text in Greek and English.
|
4
|
+
|
5
|
+
Usefull where a full text number representation is needed as in cheques and invoices.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'number_read_out'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install number_read_out
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
###Currently supports:
|
26
|
+
|
27
|
+
Languages:
|
28
|
+
:en => 'English',
|
29
|
+
:gr => 'Greek'
|
30
|
+
Currencies:
|
31
|
+
:euro => 'Euro'
|
32
|
+
:drachmas => 'Drachmas', just in case
|
33
|
+
|
34
|
+
|
35
|
+
NumberReadOut.full_currency_text(amount,currency,language)
|
36
|
+
|
37
|
+
Where amount is up to 999999999999999999,99€ that is:
|
38
|
+
|
39
|
+
NINE HUNDRED AND NINETY-NINE QUADRILLION
|
40
|
+
NINE HUNDRED AND NINETY-NINE TRILLION
|
41
|
+
NINE HUNDRED AND NINETY-NINE BILLION
|
42
|
+
NINE HUNDRED AND NINETY-NINE MILLION
|
43
|
+
NINE HUNDRED AND NINETY-NINE THOUSAND
|
44
|
+
NINE HUNDRED AND NINETY-NINE EURO
|
45
|
+
AND
|
46
|
+
NINETY-NINE EUROCENTS
|
47
|
+
|
48
|
+
or in Geek drachmas:
|
49
|
+
|
50
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΤΕΤΡΑΚΙΣΕΚΑΤΟΜΥΡΙΑ
|
51
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΤΡΙΣΕΚΑΤΟΜΥΡΙΑ
|
52
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΔΙΣΕΚΑΤΟΜΥΡΙΑ
|
53
|
+
ΕΝΝΙΑΚΟΣΙΑ ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΕΚΑΤΟΜΥΡΙΑ
|
54
|
+
ΕΝΝΙΑΚΟΣΙEΣ ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΧΙΛΙΑΔΕΣ
|
55
|
+
ΕΝΝΙΑΚΟΣΙEΣ ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΔΡΑΧΜΕΣ
|
56
|
+
ΚΑΙ
|
57
|
+
ΕΝΕΝΗΝΤΑΕΝΝΕΑ ΛΕΠΤΑ
|
58
|
+
|
59
|
+
|
60
|
+
### Caveats
|
61
|
+
|
62
|
+
For _now_ only positive currencies for up to two decimal digits are supported. Additional decimal digits are trungated.
|
63
|
+
|
64
|
+
## Development
|
65
|
+
|
66
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
67
|
+
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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
|
+
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
78
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "number_read_out"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
require "number_read_out/version"
|
2
|
+
|
3
|
+
module NumberReadOut
|
4
|
+
|
5
|
+
SpokenNumbers = {en: {male: {hundreds: ['ONE HUNDRED', 'ONE HUNDRED', 'TWO HUNDRED', 'THREE HUNDRED', 'FOUR HUNDRED', 'FIVE HUNDRED', 'SIX HUNDRED', 'SEVEN HUNDRED', 'EIGHT HUNDRED', 'NINE HUNDRED'],
|
6
|
+
dozens: ['', 'TEN', 'TWENTY', 'THIRTY', 'FORTY', 'FIFTY', 'SIXTY', 'SEVENTY', 'EIGHT', 'NINETY','TEN', 'ELEVEN', 'TWELVE', 'THIRTEEN', 'FOURTEEN', 'FIFTEEN', 'SIXTEEN', 'SEVENTEEN', 'EIGHTEEN', 'NINETEEN'],
|
7
|
+
monads: ['', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE'],
|
8
|
+
},
|
9
|
+
female: {hundreds: ['ONE HUNDRED', 'ONE HUNDRED', 'TWO HUNDRED', 'THREE HUNDRED', 'FOUR HUNDRED', 'FIVE HUNDRED', 'SIX HUNDRED', 'SEVEN HUNDRED', 'EIGHT HUNDRED', 'NINE HUNDRED'],
|
10
|
+
dozens: ['', 'TEN', 'TWENTY', 'THIRTY', 'FORTY', 'FIFTY', 'SIXTY', 'SEVENTY', 'EIGHT', 'NINETY','TEN', 'ELEVEN', 'TWELVE', 'THIRTEEN', 'FOURTEEN', 'FIFTEEN', 'SIXTEEN', 'SEVENTEEN', 'EIGHTEEN', 'NINETEEN'],
|
11
|
+
monads: ['', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE'],
|
12
|
+
},
|
13
|
+
units_singular: [ 'THOUSAND', 'THOUSAND', 'MILLION', 'BILLION', 'TRILLION', 'QUADRILLION'],
|
14
|
+
units_plural: [ 'THOUSAND', 'THOUSAND', 'MILLION', 'BILLION', 'TRILLION', 'QUADRILLION']
|
15
|
+
},
|
16
|
+
gr: {male: {hundreds: ['EKATON', 'EKATO', 'ΔΙΑΚΟΣΙA', 'ΤΡΙΑΚΟΣΙΑ', 'ΤΕΤΡΑΚΟΣΙΑ', 'ΠΕΝΤΑΚΟΣΙΑ', 'ΕΞΑΚΟΣΙΑ', 'ΕΠΤΑΚΟΣΙΑ', 'ΟΚΤΑΚΟΣΙΑ', 'ΕΝΝΙΑΚΟΣΙΑ'],
|
17
|
+
dozens: ['', 'ΔΕΚΑ', 'ΕΙΚΟΣΙ', 'ΤΡΙΑΝΤΑ', 'ΣΑΡΑΝΤΑ', 'ΠΕΝΗΝΤΑ', 'ΕΞΗΝΤΑ', 'ΕΒΔΟΜΗΝΤΑ', 'ΟΓΔΟΝΤΑ', 'ΕΝΕΝΗΝΤΑ','ΔΕΚΑ', 'ΕΝΤΕΚΑ', 'ΔΩΔΕΚΑ', 'ΔΕΚΑΤΡΙΑ', 'ΔΕΚΑΤΕΣΣΕΡΑ', 'ΔΕΚΑΠΕΝΤΕ', 'ΔΕΚΑΕΞΙ', 'ΔΕΚΑΕΠΤΑ', 'ΔΕΚΑΟΚΤΩ', 'ΔΕΚΑΕΝΝΕΑ'],
|
18
|
+
monads: ['', 'ΕΝΑ', 'ΔΥΟ', 'ΤΡΙΑ', 'ΤΕΣΣΕΡΑ', 'ΠΕΝΤΕ', 'ΕΞΙ', 'ΕΠΤΑ', 'ΟΚΤΩ', 'ΕΝΝΕΑ'],
|
19
|
+
},
|
20
|
+
female: {hundreds: ['EKATON', 'EKATO', 'ΔΙΑΚΟΣΙEΣ', 'ΤΡΙΑΚΟΣΙEΣ', 'ΤΕΤΡΑΚΟΣΙEΣ', 'ΠΕΝΤΑΚΟΣΙEΣ', 'ΕΞΑΚΟΣΙEΣ', 'ΕΠΤΑΚΟΣΙEΣ', 'ΟΚΤΑΚΟΣΙEΣ', 'ΕΝΝΙΑΚΟΣΙEΣ'],
|
21
|
+
dozens: ['', 'ΔΕΚΑ', 'ΕΙΚΟΣΙ', 'ΤΡΙΑΝΤΑ', 'ΣΑΡΑΝΤΑ', 'ΠΕΝΗΝΤΑ', 'ΕΞΗΝΤΑ', 'ΕΒΔΟΜΗΝΤΑ', 'ΟΓΔΟΝΤΑ', 'ΕΝΕΝΗΝΤΑ','ΔΕΚΑ', 'ΕΝΤΕΚΑ', 'ΔΩΔΕΚΑ', 'ΔΕΚΑΤΡΕΙΣ', 'ΔΕΚΑΤΕΣΣΕΡΙΣ', 'ΔΕΚΑΠEΝΤΕ', 'ΔΕΚΑΕΞΙ', 'ΔΕΚΑΕΠΤΑ', 'ΔΕΚΑΟΚΤΩ', 'ΔΕΚΑΕΝΝΕΑ'],
|
22
|
+
monads: ['', 'ΜΙΑ', 'ΔΥΟ', 'ΤΡΕΙΣ', 'ΤΕΣΣΕΡΙΣ', 'ΠΕΝΤΕ', 'ΕΞΙ', 'ΕΠΤΑ', 'ΟΚΤΩ', 'ΕΝΝΕΑ'],
|
23
|
+
},
|
24
|
+
units_singular: ['ΧΙΛΙΕΣ', 'ΧΙΛΙΑ', 'ΕΚΑΤΟΜΥΡΙΟ', 'ΔΙΣΕΚΑΤΟΜΥΡΙΟ', 'ΤΡΙΣΕΚΑΤΟΜΥΡΙΟ', 'ΤΕΤΡΑΚΙΣΕΚΑΤΟΜΥΡΙΟ'],
|
25
|
+
units_plural: [ 'ΧΙΛΙΑΔΕΣ', 'ΧΙΛΙΑΔΕΣ', 'ΕΚΑΤΟΜΥΡΙΑ', 'ΔΙΣΕΚΑΤΟΜΥΡΙΑ', 'ΤΡΙΣΕΚΑΤΟΜΥΡΙΑ', 'ΤΕΤΡΑΚΙΣΕΚΑΤΟΜΥΡΙΑ']
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
SpokenCurrencies = {en: {euro: ['EURO','EUROCENTS','EUROCENTS', 'AND','-'],drachmas:['DRACHMAS','CENTS','CENTS','AND','-']},
|
30
|
+
gr: {euro: ['ΕΥΡΩ','ΕΥΡΩΛΕΠΤΟ','ΕΥΡΩΛΕΠΤΑ', 'ΚΑΙ',''],drachmas:['ΔΡΑΧΜΕΣ','ΛΕΠΤΟ','ΛΕΠΤΑ', 'ΚΑΙ','']}}
|
31
|
+
|
32
|
+
PartOfNumber = [:hundreds, :thousands, :millions, :billions, :trillions, :quadrillions]
|
33
|
+
|
34
|
+
def self.decimal_part_to_text(douplet,currency = :euro,lang = :gr)
|
35
|
+
return '' if douplet == 0
|
36
|
+
|
37
|
+
raise ArgumentError.new("Wrong douplet #{douplet}") if douplet > 99
|
38
|
+
|
39
|
+
dozens, monads = douplet.divmod 10
|
40
|
+
|
41
|
+
if douplet >10 and douplet < 20
|
42
|
+
textual = SpokenNumbers[lang][:male][:dozens][douplet]
|
43
|
+
else
|
44
|
+
textual = SpokenNumbers[lang][:male][:dozens][dozens]
|
45
|
+
if monads != 0
|
46
|
+
textual += SpokenCurrencies[lang][currency][4] if dozens >1 # add dash (-) if needed
|
47
|
+
textual += SpokenNumbers[lang][:male][:monads][monads]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
textual + ' ' +( SpokenCurrencies[lang][currency][douplet == 1 ? 1:2] )
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.triplet_to_text(
|
54
|
+
triplet,
|
55
|
+
part_of_number,
|
56
|
+
currency = :euro,
|
57
|
+
lang = :gr)
|
58
|
+
return '' if triplet == 0
|
59
|
+
raise ArgumentError.new("Wrong triplet #{triplet}") if triplet > 999
|
60
|
+
hundreds, teens = triplet.divmod 100
|
61
|
+
dozens, monads = teens.divmod 10
|
62
|
+
|
63
|
+
genus = (([:hundreds, :thousands].include? part_of_number) and currency != :euro) ? :female : :male
|
64
|
+
|
65
|
+
textual = ''
|
66
|
+
|
67
|
+
if hundreds != 0
|
68
|
+
hundreds_corrector = (teens != 0 and hundreds==1) ? 1 : 0
|
69
|
+
textual += SpokenNumbers[lang][genus][:hundreds][hundreds - hundreds_corrector ]
|
70
|
+
if teens >0
|
71
|
+
textual += ' '
|
72
|
+
textual += SpokenCurrencies[:en][:euro][3] + ' ' if lang == :en
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if teens != 0
|
77
|
+
if teens >10 and teens < 20
|
78
|
+
textual += SpokenNumbers[lang][genus][:dozens][teens]
|
79
|
+
else
|
80
|
+
textual += SpokenNumbers[lang][genus][:dozens][dozens]
|
81
|
+
if monads != 0
|
82
|
+
textual +=SpokenCurrencies[lang][currency][4] if dozens >1
|
83
|
+
textual += SpokenNumbers[lang][genus][:monads][monads] unless lang == :gr and part_of_number==:thousands and monads==1
|
84
|
+
textual += ' ' if ((monads >1 or lang == :en) and part_of_number==:thousands) or not [ :hundreds, :thousands].include? part_of_number
|
85
|
+
else
|
86
|
+
textual += ' ' unless part_of_number == :hundreds
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
units = ((hundreds == 1 or monads==1) and dozens==0) ? :units_singular : :units_plural
|
92
|
+
|
93
|
+
if part_of_number != :hundreds
|
94
|
+
thousands_corrector = (units == :units_singular && genus == :female) ? 1 : 0
|
95
|
+
textual += SpokenNumbers[lang][units][PartOfNumber.index(part_of_number) - thousands_corrector]
|
96
|
+
end
|
97
|
+
textual += ' ' if triplet >0
|
98
|
+
textual
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.full_currency_text(amount_str, currency= :euro,lang= :gr)
|
103
|
+
|
104
|
+
raise ArgumentError.new("Parameter amount: expecting string") unless amount_str.is_a?(String)
|
105
|
+
|
106
|
+
dots = amount_str.count('.')
|
107
|
+
commas = amount_str.count(',')
|
108
|
+
raise ArgumentError.new("Parameter amount: too many dots or commas") if dots >1 or commas >1
|
109
|
+
|
110
|
+
# split integer, decimal part
|
111
|
+
integer_part_of_number,decimal_part_of_number = amount_str.split(dots==1? '.': ',')
|
112
|
+
|
113
|
+
integer_part_of_number = integer_part_of_number.to_i
|
114
|
+
raise ArgumentError.new("Integer part too long") if integer_part_of_number > 999999999999999999
|
115
|
+
|
116
|
+
decimal_part_of_number = (decimal_part_of_number ? decimal_part_of_number[0..1].to_i : 0)
|
117
|
+
decimal_part_text = decimal_part_to_text(decimal_part_of_number, currency,lang)
|
118
|
+
|
119
|
+
integer_part_text = ''
|
120
|
+
PartOfNumber.each do |part_of_number|
|
121
|
+
integer_part_of_number, triplet = integer_part_of_number.divmod(1000)
|
122
|
+
break if integer_part_of_number == 0 and triplet == 0
|
123
|
+
integer_part_text = triplet_to_text(triplet, part_of_number, currency,lang) + integer_part_text
|
124
|
+
integer_part_text += SpokenCurrencies[lang][currency][0] if integer_part_of_number == 0
|
125
|
+
end
|
126
|
+
raise ArgumentError.new("Number too long to parse...") if integer_part_of_number >0
|
127
|
+
|
128
|
+
integer_part_text + ((integer_part_text !='' and decimal_part_text !='')? ' ' + SpokenCurrencies[lang][currency][3] + ' ' : '') +decimal_part_text
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'number_read_out/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "number_read_out"
|
8
|
+
spec.version = NumberReadOut::VERSION
|
9
|
+
spec.authors = ["Michail Pantelelis"]
|
10
|
+
spec.email = ["mpantel@aegean.gr"]
|
11
|
+
|
12
|
+
spec.summary = "Utility gem to convert numbers/currencies to text in Greek and English."
|
13
|
+
spec.description = %q{Convert numbers and currencies to text in Greek and English. Usefull where a full text number representation is needed as in cheques and invoices.}
|
14
|
+
spec.homepage = "https://github.com/mpantel/number_read_out"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: number_read_out
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michail Pantelelis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Convert numbers and currencies to text in Greek and English. Usefull
|
56
|
+
where a full text number representation is needed as in cheques and invoices.
|
57
|
+
email:
|
58
|
+
- mpantel@aegean.gr
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/number_read_out.rb
|
73
|
+
- lib/number_read_out/version.rb
|
74
|
+
- number_read_out.gemspec
|
75
|
+
homepage: https://github.com/mpantel/number_read_out
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Utility gem to convert numbers/currencies to text in Greek and English.
|
99
|
+
test_files: []
|