Class: SoundGame
- Inherits:
-
Object
- Object
- SoundGame
- Defined in:
- lib/learn-japanese/game/sound-game.rb
Instance Method Summary collapse
-
#initialize ⇒ SoundGame
constructor
A new instance of SoundGame.
- #run ⇒ Object
- #to_hiragana(sounds) ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/learn-japanese/game/sound-game.rb', line 23 def run Debug.puts_line puts "SOUNDS TO HIRAGANA".light_cyan puts "Example: a i => あい (amor - ái)".blue Debug.puts_line loop do print "\nWrite sounds ? ".light_yellow sounds = STDIN.gets.chomp.split return if sounds.empty? word = to_hiragana(sounds) print "Hiragana => ".white puts word["hiragana"] print "Spanish => ".white puts word["spanish"] print "Pronounce => ".white puts word["sounds"] end end |
#to_hiragana(sounds) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/learn-japanese/game/sound-game.rb', line 13 def to_hiragana(sounds) hiragana = @hiragana.sounds_to_hiragana(sounds) none = {'hiragana' => hiragana, 'spanish' => '?', 'sounds' => '?'} words = Dictionary.words word = (words.select {_1["hiragana"] == hiragana})[0] || none word end |