Class: Exam::Quiz
- Inherits:
-
Object
- Object
- Exam::Quiz
- Defined in:
- lib/exam/quiz.rb
Instance Attribute Summary collapse
-
#nombre ⇒ Object
Returns the value of attribute nombre.
-
#preguntas ⇒ Object
Returns the value of attribute preguntas.
Instance Method Summary collapse
-
#initialize(nombre, &block) ⇒ Quiz
constructor
A new instance of Quiz.
- #question(nombre, opciones = {}) ⇒ Object
- #run ⇒ Object
- #wrong ⇒ Object
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
#nombre ⇒ Object
Returns the value of attribute nombre.
5 6 7 |
# File 'lib/exam/quiz.rb', line 5 def nombre @nombre end |
#preguntas ⇒ Object
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 |
#run ⇒ Object
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 |
#wrong ⇒ Object
28 29 30 |
# File 'lib/exam/quiz.rb', line 28 def wrong @count += 1 end |