Class: BeforeGame::Hint

Inherits:
Object
  • Object
show all
Defined in:
lib/codebreaker/before_game/hint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hints_count:) ⇒ Hint

Returns a new instance of Hint.



7
8
9
# File 'lib/codebreaker/before_game/hint.rb', line 7

def initialize(hints_count:)
  @hints_count = hints_count
end

Instance Attribute Details

#hints_countObject

Returns the value of attribute hints_count.



5
6
7
# File 'lib/codebreaker/before_game/hint.rb', line 5

def hints_count
  @hints_count
end

#hints_itemsObject

Returns the value of attribute hints_items.



5
6
7
# File 'lib/codebreaker/before_game/hint.rb', line 5

def hints_items
  @hints_items
end

Instance Method Details

#generate_hints(code) ⇒ Object



11
12
13
# File 'lib/codebreaker/before_game/hint.rb', line 11

def generate_hints(code)
  @hints_items = code.sample(@hints_count)
end

#hintObject



15
16
17
18
19
# File 'lib/codebreaker/before_game/hint.rb', line 15

def hint
  return false if @hints_count.zero?

  @hints_items.pop
end