Class: QuizDsl::Question
- Inherits:
-
Object
- Object
- QuizDsl::Question
- Defined in:
- lib/quiz_dsl.rb
Overview
Clase que representa una de pregunta a un test.
Instance Attribute Summary collapse
-
#answers ⇒ Object
Returns the value of attribute answers.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, anss) ⇒ Question
constructor
A new instance of Question.
- #to_s ⇒ Object
Constructor Details
#initialize(title, anss) ⇒ Question
Returns a new instance of Question.
81 82 83 84 85 |
# File 'lib/quiz_dsl.rb', line 81 def initialize(title, anss) raise ArgumentError, "El título tiene que ser una cadena" unless title.is_a? String @title = title @answers = anss end |
Instance Attribute Details
#answers ⇒ Object
Returns the value of attribute answers.
79 80 81 |
# File 'lib/quiz_dsl.rb', line 79 def answers @answers end |
#title ⇒ Object
Returns the value of attribute title.
79 80 81 |
# File 'lib/quiz_dsl.rb', line 79 def title @title end |
Instance Method Details
#to_s ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/quiz_dsl.rb', line 86 def to_s out = " #{@title}" + "\n" i = 1 answers.each do |a| out << " [#{i}] #{a}\n" i += 1 end out end |