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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19a723c4c559e30427f29aa93167d371b87225a1
4
- data.tar.gz: 98cac54ab9cdd736b1b34ced1a6a6c66b7329a75
3
+ metadata.gz: aadcd8ef8da0e7c948f3ae6b843e1eb619b232d7
4
+ data.tar.gz: b0cfeaf9fd6009cfa9e6782dd8d9afb188f638ef
5
5
  SHA512:
6
- metadata.gz: 254d25bb30825309957592cb4101b1f39b9b42fb4e1875d4f71bd44e17ab190a9442c0e41280e8024b4d949a6ecb54e37b9d900b7d3c7e949642bbc0625165eb
7
- data.tar.gz: e2d3251c828c1d098989b1c4e35b790cb9adbef157cd59d1d481d86557e4e2ab5039e6a31e3c7e49ff05f48dc56ced01f23f80e3b68e7da24a1fdde5a8b597d1
6
+ metadata.gz: 261c9ebc3abaff16c3deea3b35c27e48d5f968e7b2bb60b54704db9e993715b97449849481a9b2e144c40b62b360cabeb8ff106147014be37fd496eeb23e9775
7
+ data.tar.gz: d36085543f463f4fc84da0e4c105269a4fdce8540a897365902e0fce48b968a3b45fcb01bc82bae844cf90993d39481184548a3ee56336dc398ca09ec1d61574
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in number_read_out.gemspec
4
- gemspec
4
+ gemspec
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/[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.
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
@@ -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: ['EKATON', 'EKATO', 'ΔΙΑΚΟΣΙA', 'ΤΡΙΑΚΟΣΙΑ', 'ΤΕΤΡΑΚΟΣΙΑ', 'ΠΕΝΤΑΚΟΣΙΑ', 'ΕΞΑΚΟΣΙΑ', 'ΕΠΤΑΚΟΣΙΑ', 'ΟΚΤΑΚΟΣΙΑ', 'ΕΝΝΙΑΚΟΣΙΑ'],
16
+ gr: {male: {hundreds: ['ΕΚΑΤΟΝ', 'ΕΚΑΤΟ', 'ΔΙΑΚΟΣΙA', 'ΤΡΙΑΚΟΣΙΑ', 'ΤΕΤΡΑΚΟΣΙΑ', 'ΠΕΝΤΑΚΟΣΙΑ', 'ΕΞΑΚΟΣΙΑ', 'ΕΠΤΑΚΟΣΙΑ', 'ΟΚΤΑΚΟΣΙΑ', 'ΕΝΝΙΑΚΟΣΙΑ'],
17
17
  dozens: ['', 'ΔΕΚΑ', 'ΕΙΚΟΣΙ', 'ΤΡΙΑΝΤΑ', 'ΣΑΡΑΝΤΑ', 'ΠΕΝΗΝΤΑ', 'ΕΞΗΝΤΑ', 'ΕΒΔΟΜΗΝΤΑ', 'ΟΓΔΟΝΤΑ', 'ΕΝΕΝΗΝΤΑ','ΔΕΚΑ', 'ΕΝΤΕΚΑ', 'ΔΩΔΕΚΑ', 'ΔΕΚΑΤΡΙΑ', 'ΔΕΚΑΤΕΣΣΕΡΑ', 'ΔΕΚΑΠΕΝΤΕ', 'ΔΕΚΑΕΞΙ', 'ΔΕΚΑΕΠΤΑ', 'ΔΕΚΑΟΚΤΩ', 'ΔΕΚΑΕΝΝΕΑ'],
18
18
  monads: ['', 'ΕΝΑ', 'ΔΥΟ', 'ΤΡΙΑ', 'ΤΕΣΣΕΡΑ', 'ΠΕΝΤΕ', 'ΕΞΙ', 'ΕΠΤΑ', 'ΟΚΤΩ', 'ΕΝΝΕΑ'],
19
19
  },
20
- female: {hundreds: ['EKATON', 'EKATO', 'ΔΙΑΚΟΣΙEΣ', 'ΤΡΙΑΚΟΣΙEΣ', 'ΤΕΤΡΑΚΟΣΙEΣ', 'ΠΕΝΤΑΚΟΣΙEΣ', 'ΕΞΑΚΟΣΙEΣ', 'ΕΠΤΑΚΟΣΙEΣ', 'ΟΚΤΑΚΟΣΙEΣ', 'ΕΝΝΙΑΚΟΣΙEΣ'],
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 and hundreds==1) ? 1 : 0
68
+ hundreds_corrector = (teens != 0 and hundreds==1 ) ? 1 : 0
69
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
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
- 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
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 += ' ' if triplet >0
99
+ textual += ' '
98
100
  textual
99
101
 
100
102
  end
@@ -1,3 +1,3 @@
1
1
  module NumberReadOut
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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'] = "TODO: Set to 'http://mygemserver.com'"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: number_read_out
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michail Pantelelis