Module: SoundGame
- Defined in:
- lib/learn-japanese/game/sound-game.rb
Class Method Summary collapse
Class Method Details
.run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/learn-japanese/game/sound-game.rb', line 19 def self.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 = self.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
9 10 11 12 13 14 15 16 17 |
# File 'lib/learn-japanese/game/sound-game.rb', line 9 def self.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 |