Class: Respanol::Examen::HoraExamen

Inherits:
ExamenBase show all
Defined in:
lib/respanol/examenes/hora_examen.rb

Constant Summary

Constants inherited from ExamenBase

ExamenBase::GAZA_CONDE

Instance Method Summary collapse

Methods inherited from ExamenBase

#decir_que_no, emparejar?, #emparejar?, #ensayar, #felicitar, #gaza, gaza, #optener, #pedir

Methods included from Impresion

included

Instance Method Details

#escribir(from = 0, to = 24) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/respanol/examenes/hora_examen.rb', line 15

def escribir(from = 0, to = 24)
  fe = Date.today
  ho = Time.local(fe.year, fe.month, fe.day, rand(from..to), rand(0..60), rand(0..60))
  ensayar("#{ho.strftime('%I:%M:%S %p')} = ") do |v|
    emparejar?(v, Hora.responder_hora_en_palabras(ho))
  end
end

#leer(from = 0, to = 24) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/respanol/examenes/hora_examen.rb', line 4

def leer(from = 0, to = 24)
  fe = Date.today
  ho = Time.local(fe.year, fe.month, fe.day, rand(from..to), rand(0..60), rand(0..60))
  ensayar("#{Hora.responder_hora_en_palabras(ho)} = ") do |v|
    m = /(\d+)[^\d]+(\d+)/.match(v)
    if m
      m[1].to_i == (ho.hour % 12) && m[2].to_i == ho.min
    end
  end
end