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
15
# File 'lib/exam/quiz.rb', line 7

def initialize(nombre, &block)

  @nombre = nombre
  @preguntas = []
  @count = 0

  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



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

def question(nombre, opciones = {})
  respuestas = []
  opciones.each do |key, value|
    respuestas << value
  end
  pregunta = Test.new(nombre,opciones[:right],respuestas)

  @preguntas << pregunta

end

#runObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/exam/quiz.rb', line 32

def run
  l = DList.new(@preguntas)

  e=Examen.new(l)

  i=Interfaz.new(e)

  i.examinar

end

#wrongObject



28
29
30
# File 'lib/exam/quiz.rb', line 28

def wrong
  @count += 1
end