Class: Escape::Question
- Inherits:
-
Object
- Object
- Escape::Question
- Defined in:
- lib/escape/question.rb
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #correct?(answer) ⇒ Boolean
-
#initialize(text, answer: nil) ⇒ Question
constructor
A new instance of Question.
Constructor Details
#initialize(text, answer: nil) ⇒ Question
Returns a new instance of Question.
5 6 7 8 |
# File 'lib/escape/question.rb', line 5 def initialize(text, answer: nil) @text = text @answer = answer end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
3 4 5 |
# File 'lib/escape/question.rb', line 3 def answer @answer end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/escape/question.rb', line 3 def text @text end |
Class Method Details
.load(question) ⇒ Object
15 16 17 |
# File 'lib/escape/question.rb', line 15 def load(question) new(question["text"], answer: question["answer"]) end |
Instance Method Details
#correct?(answer) ⇒ Boolean
10 11 12 |
# File 'lib/escape/question.rb', line 10 def correct?(answer) self.answer.to_s == answer end |