Class: Escape::Clue
- Inherits:
-
Object
- Object
- Escape::Clue
- Defined in:
- lib/escape/clue.rb
Instance Attribute Summary collapse
-
#clues ⇒ Object
readonly
Returns the value of attribute clues.
Instance Method Summary collapse
- #correct(index) ⇒ Object
- #incorrect(index) ⇒ Object
-
#initialize(clues) ⇒ Clue
constructor
A new instance of Clue.
Constructor Details
#initialize(clues) ⇒ Clue
Returns a new instance of Clue.
5 6 7 |
# File 'lib/escape/clue.rb', line 5 def initialize(clues) @clues = clues end |
Instance Attribute Details
#clues ⇒ Object (readonly)
Returns the value of attribute clues.
3 4 5 |
# File 'lib/escape/clue.rb', line 3 def clues @clues end |
Instance Method Details
#correct(index) ⇒ Object
9 10 11 |
# File 'lib/escape/clue.rb', line 9 def correct(index) clues[index] end |
#incorrect(index) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/escape/clue.rb', line 13 def incorrect(index) correct = self.correct(index) return ([*0..99] - [correct]).sample if correct.is_a?(Integer) return ([*"A".."Z"] - [correct]).sample if correct.is_a?(String) end |