Class: Ankh::Question
- Inherits:
-
Object
- Object
- Ankh::Question
- Defined in:
- lib/ankh/question.rb
Constant Summary collapse
- OPERATIONS =
[ "+", "-" ]
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#first_number ⇒ Object
readonly
Returns the value of attribute first_number.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#question ⇒ Object
readonly
Returns the value of attribute question.
-
#second_number ⇒ Object
readonly
Returns the value of attribute second_number.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Question
constructor
A new instance of Question.
Constructor Details
#initialize ⇒ Question
Returns a new instance of Question.
10 11 12 13 14 15 16 17 |
# File 'lib/ankh/question.rb', line 10 def initialize @second_number = rand(9) @first_number = @second_number + rand(9) @operation = OPERATIONS[rand(2)] @question = "What is #{first_number} #{operation} #{second_number}?" @answer = @first_number.send(@operation, @second_number) end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
8 9 10 |
# File 'lib/ankh/question.rb', line 8 def answer @answer end |
#first_number ⇒ Object (readonly)
Returns the value of attribute first_number.
8 9 10 |
# File 'lib/ankh/question.rb', line 8 def first_number @first_number end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
8 9 10 |
# File 'lib/ankh/question.rb', line 8 def operation @operation end |
#question ⇒ Object (readonly)
Returns the value of attribute question.
8 9 10 |
# File 'lib/ankh/question.rb', line 8 def question @question end |
#second_number ⇒ Object (readonly)
Returns the value of attribute second_number.
8 9 10 |
# File 'lib/ankh/question.rb', line 8 def second_number @second_number end |
Class Method Details
.generate ⇒ Object
19 20 21 |
# File 'lib/ankh/question.rb', line 19 def self.generate new end |