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
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
#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
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 |