money_to_text 0.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +64 -0
  3. data/lib/money_to_text.rb +130 -0
  4. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: db751d4e1c825301c72960a115201b638cbe2e978cdb8853978b15c472b912f8
4
+ data.tar.gz: c52a6a83cf7025497b957ee098dbb7956c070e02fa0174f02cec5df8a1cd775b
5
+ SHA512:
6
+ metadata.gz: b443421be25b708e971bf6fc55c9c08004a066046adbc4c54a1033037a6f5e6d41d2c4d4ad408b40da7c92b69d33471c99f756a941fba87d3a0b3538e78e393a
7
+ data.tar.gz: cac112fad336f928e48ead981bda850a7cca1c55927b562cd3dd07d023902c983ba02990d13abcafb84d28a9be39b644d32386e86182ac3687f81fe1d0efebe3
@@ -0,0 +1,64 @@
1
+ # Festivos Colombia
2
+
3
+ _Proyecto creado para obtener un listado de fechas festivas en Colombia_
4
+
5
+ ### Pre-requisitos 📋
6
+
7
+ _Que cosas necesitas para instalar la gema_
8
+
9
+ ```
10
+ Ruby
11
+ ```
12
+
13
+ ### Instalación 🔧
14
+
15
+ **Gemfile**
16
+ ```gem 'festivoscolombia', '~> 0.0.1'```
17
+
18
+ **Install**
19
+ ```gem install festivoscolombia```
20
+
21
+ ## Ejecutando las pruebas ⚙️
22
+ _Para probar la Gema en la consola de ruby_
23
+
24
+ ```gem install festivoscolombia```
25
+
26
+
27
+ ![alt text](https://github.com/dario1091/Festivos_Colombia/blob/master/images/install.PNG)}
28
+
29
+
30
+ consola de ruby
31
+ ```irb```
32
+
33
+ ```require 'festivoscolombia'```
34
+
35
+ ![alt text](https://github.com/dario1091/Festivos_Colombia/blob/master/images/console%20ruby.PNG)}
36
+
37
+
38
+ Prueba con año dado
39
+
40
+ ```Festivoscolombia.generar_festivos(1991)```
41
+
42
+ ![alt text](https://github.com/dario1091/Festivos_Colombia/blob/master/images/generate_with_year.PNG)}
43
+
44
+ Prueba sin año
45
+
46
+ _por default trae los festivos del año en curso en este caso 2020_
47
+
48
+ ```Festivoscolombia.generar_festivos()```
49
+
50
+ ![alt text](https://github.com/dario1091/Festivos_Colombia/blob/master/images/generate_without_year.PNG)}
51
+
52
+ ## Consultar una fecha
53
+
54
+ _Para consultar una fecha especifica_
55
+
56
+
57
+ ```Festivoscolombia.generar_festivos(2020).include?("2020-04-01")```
58
+
59
+ ![alt text](https://github.com/dario1091/Festivos_Colombia/blob/master/images/include.PNG)}
60
+
61
+
62
+
63
+
64
+
@@ -0,0 +1,130 @@
1
+ #Archivo Gema_festivos_colombia/festivos_colombia.rb
2
+
3
+ require "date"
4
+
5
+ class MoneyToText
6
+ def self.get_text(money = "1345798")
7
+ parteEntera = money.to_i
8
+ triUnidades = ((parteEntera % 1000))
9
+ triMiles = ((parteEntera / 1000) % 1000)
10
+ triMillones = ((parteEntera / 1000000) % 1000)
11
+ triMilMillones = ((parteEntera / 1000000000) % 1000)
12
+
13
+ response = ""
14
+ return "Cero" if parteEntera == 0
15
+
16
+ if triMilMillones > 0
17
+ response << triTexto(triMilMillones) << " Mil"
18
+ end
19
+
20
+ if triMillones > 0
21
+ response << triTexto(triMillones)
22
+ end
23
+
24
+ if triMilMillones == 0 && triMillones == 1
25
+ response << "Millón "
26
+ else
27
+ response << "Millones "
28
+ end
29
+
30
+ if triMiles > 0
31
+ response << triTexto(triMiles) << "Mil "
32
+ end
33
+
34
+ if triUnidades > 0
35
+ response << triTexto(triUnidades)
36
+ end
37
+ money << " = " << response
38
+ end
39
+
40
+ def self.triTexto(n)
41
+ response = ""
42
+ centenas = n / 100
43
+ decenas = (n % 100) / 10
44
+ unidades = (n % 10)
45
+
46
+ case centenas
47
+ when 0
48
+ when 1
49
+ if decenas == 0 && unidades == 0
50
+ return "cien "
51
+ else
52
+ response << "Ciento "
53
+ end
54
+ when 2
55
+ response << "doscientos "
56
+ when 3
57
+ response << "trescientos "
58
+ when 4
59
+ response << "cuatrocientos "
60
+ when 5
61
+ response << "quinientos "
62
+ when 6
63
+ response << "seiscientos "
64
+ when 7
65
+ response << "setecientos "
66
+ when 8
67
+ response << "ochocientos "
68
+ when 9
69
+ response << "novecientos "
70
+ end
71
+
72
+ case decenas
73
+ when 0
74
+ when 1
75
+ return response << "diez " if unidades.zero?
76
+ return response << "once " if unidades == 1
77
+ return response << "doce " if unidades == 2
78
+ return response << "trece " if unidades == 3
79
+ return response << "catorce " if unidades == 4
80
+ return response << "quince " if unidades == 5
81
+ return response << "Dieci"
82
+ when 2
83
+ unidades == 0 ? response << "veinte " : response << "veinti"
84
+ return response
85
+ when 3
86
+ response << "treinta "
87
+ when 4
88
+ response << "cuarenta "
89
+ when 5
90
+ response << "cincuenta "
91
+ when 6
92
+ response << "sesenta "
93
+ when 7
94
+ response << "setenta "
95
+ when 8
96
+ response << "ochenta "
97
+ when 9
98
+ response << "noventa "
99
+ end
100
+
101
+ if decenas > 2 && unidades > 0
102
+ response << "y "
103
+ end
104
+
105
+ case unidades
106
+ when 0
107
+ when 1
108
+ response << "un "
109
+ when 2
110
+ response << "dos "
111
+ when 3
112
+ response << "tres "
113
+ when 4
114
+ response << "cuatro "
115
+ when 5
116
+ response << "cinco "
117
+ when 6
118
+ response << "seis "
119
+ when 7
120
+ response << "siete "
121
+ when 8
122
+ response << "ocho "
123
+ when 9
124
+ response << "nueve "
125
+ end
126
+ return response
127
+ end
128
+
129
+ puts get_text()
130
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: money_to_text
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dario Paez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Pasa valores numericos a su equivalente en letras
14
+ email:
15
+ - dario1091@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - lib/money_to_text.rb
22
+ homepage: https://rubygems.org/gems/festivoscolombia
23
+ licenses:
24
+ - MIT
25
+ metadata:
26
+ source_code_uri: https://github.com/dario1091/festivoscolombia.git
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.0.3
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Pase valores numericos a letras
46
+ test_files: []