Class: Exam::Quiz

Inherits:
Object
  • Object
show all
Defined in:
lib/exam/quiz.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, &block) ⇒ Quiz

Returns a new instance of Quiz.



7
8
9
10
11
12
13
14
# File 'lib/exam/quiz.rb', line 7

def initialize(nombre, &block)

  @nombre = nombre
  @preguntas = []

  instance_eval &block

end

Instance Attribute Details

#nombreObject

Returns the value of attribute nombre.



5
6
7
# File 'lib/exam/quiz.rb', line 5

def nombre
  @nombre
end

#preguntasObject

Returns the value of attribute preguntas.



5
6
7
# File 'lib/exam/quiz.rb', line 5

def preguntas
  @preguntas
end

Instance Method Details

#question(nombre, opciones = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/exam/quiz.rb', line 16

def question(nombre, opciones = {})
  respuestas = []
  respuestas << opciones[:right]
  respuestas << opciones[:wrong]
  pregunta = Test.new(nombre,opciones[:right],respuestas)

  @preguntas << pregunta

end

#runObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/exam/quiz.rb', line 26

def run
  l = DList.new(@preguntas)

  e=Examen.new(l)

  i=Interfaz.new(e)

  i.examinar

end