Class: BeforeGame::Hint
- Inherits:
-
Object
- Object
- BeforeGame::Hint
- Defined in:
- lib/codebreaker/before_game/hint.rb
Instance Attribute Summary collapse
-
#hints_count ⇒ Object
Returns the value of attribute hints_count.
-
#hints_items ⇒ Object
Returns the value of attribute hints_items.
Instance Method Summary collapse
- #generate_hints(code) ⇒ Object
- #hint ⇒ Object
-
#initialize(hints_count:) ⇒ Hint
constructor
A new instance of Hint.
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_count ⇒ Object
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_items ⇒ Object
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 |
#hint ⇒ Object
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 |