Class: Respanol::Hora
- Inherits:
-
Object
- Object
- Respanol::Hora
- Defined in:
- lib/respanol/hora.rb
Class Method Summary collapse
- .comienzo(hora) ⇒ Object
- .hora_en_palabras(hora) ⇒ Object
- .responder_hora_en_palabras(hora) ⇒ Object
Class Method Details
.comienzo(hora) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/respanol/hora.rb', line 7 def self.comienzo(hora) h = hora.hour % 12 m = hora.min if h == 1 && m <= 30 "Es la" else "Son las" end end |
.hora_en_palabras(hora) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/respanol/hora.rb', line 17 def self.hora_en_palabras(hora) h = hora.hour % 12 m = hora.min s_h = if m <= 30 FemininoNumero.numero_en_palabras(h) else FemininoNumero.numero_en_palabras(h + 1) end s_m = case m when 0 'en punto' when 15 'y cuarto' when 30 'y media' else if m < 30 "y #{FemininoNumero.numero_en_palabras(m)}" else "menos #{FemininoNumero.numero_en_palabras(60 - m)}" end end "#{s_h} #{s_m}" end |
.responder_hora_en_palabras(hora) ⇒ Object
3 4 5 |
# File 'lib/respanol/hora.rb', line 3 def self.responder_hora_en_palabras(hora) "#{comienzo(hora)} #{hora_en_palabras(hora)}" end |