Class: PreguntaS
Overview
Pregunta de respuesta múltiple
Instance Attribute Summary collapse
-
#re ⇒ Object
readonly
Returns the value of attribute re.
Attributes inherited from Pregunta
Instance Method Summary collapse
-
#addr(respuesta) ⇒ Object
Agrega una respuesta adicional a la pregunta.
-
#initialize(pregunta, dificultad = 5) ⇒ PreguntaS
constructor
Constructor.
-
#preg ⇒ Object
Método que devuelve la pregunta como String.
-
#resp ⇒ Object
Devuelve las respuestas como String.
-
#to_s ⇒ Object
Muestra la pregunta y sus posibles respuestas como una String.
Methods inherited from Pregunta
Constructor Details
#initialize(pregunta, dificultad = 5) ⇒ PreguntaS
Constructor
8 9 10 11 12 |
# File 'lib/exam/pregunta.rb', line 8 def initialize (pregunta, dificultad = 5) super @re = Array.new(0) #inicializamos un array con 0 elementos para las respuestas end |
Instance Attribute Details
#re ⇒ Object (readonly)
Returns the value of attribute re.
5 6 7 |
# File 'lib/exam/pregunta.rb', line 5 def re @re end |
Instance Method Details
#addr(respuesta) ⇒ Object
Agrega una respuesta adicional a la pregunta
20 21 22 |
# File 'lib/exam/pregunta.rb', line 20 def addr (respuesta) @re.push(respuesta) end |
#preg ⇒ Object
Método que devuelve la pregunta como String
15 16 17 |
# File 'lib/exam/pregunta.rb', line 15 def preg "Pregunta: #{@pr}" end |
#resp ⇒ Object
Devuelve las respuestas como String
25 26 27 28 29 30 31 |
# File 'lib/exam/pregunta.rb', line 25 def resp respuestas = "" for i in (0..(@re.length - 1)) respuestas += "#{i+1}) #{@re[i]}\n" end respuestas end |
#to_s ⇒ Object
Muestra la pregunta y sus posibles respuestas como una String
34 35 36 |
# File 'lib/exam/pregunta.rb', line 34 def to_s preg + "\n\n" + resp end |