Class: Escape::Clue

Inherits:
Object
  • Object
show all
Defined in:
lib/escape/clue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#cluesObject (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