Class: ShortAnswerGame
- Inherits:
-
Object
- Object
- ShortAnswerGame
- Defined in:
- lib/learn-japanese/game/short-answer-game.rb
Instance Method Summary collapse
-
#initialize(level = 1, max = 10) ⇒ ShortAnswerGame
constructor
A new instance of ShortAnswerGame.
- #run ⇒ Object
- #show_help(level = 1) ⇒ Object
Constructor Details
#initialize(level = 1, max = 10) ⇒ ShortAnswerGame
Returns a new instance of ShortAnswerGame.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/learn-japanese/game/short-answer-game.rb', line 8 def initialize(level=1, max=10) @hiragana = Hiragana.new @level = level @score = 1 @max_score = max @silabario = @hiragana.groups( (1..level).to_a ) @keys = @silabario.keys end |
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/learn-japanese/game/short-answer-game.rb', line 24 def run @hiragana.show_help(@level) Debug.puts_line while @score < @max_score @keys.shuffle! guess_japanise_symbol(@keys[0]) end end |
#show_help(level = 1) ⇒ Object
20 21 22 |
# File 'lib/learn-japanese/game/short-answer-game.rb', line 20 def show_help(level=1) @hiragana.show_help(level) end |