Class: Answer
- Inherits:
-
Object
- Object
- Answer
- Defined in:
- lib/answer.rb
Overview
Class to model user input
Direct Known Subclasses
Instance Attribute Summary collapse
-
#answer ⇒ Object
Returns the value of attribute answer.
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(answer) ⇒ Answer
constructor
A new instance of Answer.
- #quit_game? ⇒ Boolean
Constructor Details
#initialize(answer) ⇒ Answer
Returns a new instance of Answer.
7 8 9 10 11 |
# File 'lib/answer.rb', line 7 def initialize(answer) @answer = answer.chomp.downcase.strip @errors = [] exit if quit_game? end |
Instance Attribute Details
#answer ⇒ Object
Returns the value of attribute answer.
5 6 7 |
# File 'lib/answer.rb', line 5 def answer @answer end |
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/answer.rb', line 5 def errors @errors end |
Instance Method Details
#quit_game? ⇒ Boolean
13 14 15 |
# File 'lib/answer.rb', line 13 def quit_game? answer == 'quit game' end |