i found almost what i was looking for:

class Test2
  def initialize
    vowels = Hash['a'=>'あ', 'i'=>'い', 'u'=>'う', 'e'=>'え', 'o'=>'お']


    letter = gets.chomp.downcase

    while letter != 'q'
      if letter == 'a'
        print "#{vowels['a']}"
        letter = gets.chomp.downcase
      elsif letter == 'i'
        print "#{vowels['i']}"
        letter = gets.chomp.downcase
      elsif letter == 'u'
        print "#{vowels['u']}"
        letter = gets.chomp.downcase
      elsif letter == 'e'
        print "#{vowels['e']}"
        letter = gets.chomp.downcase
      elsif letter == 'o'
        print "#{vowels['o']}"
        letter = gets.chomp.downcase
      else
        puts "This letter is not part of hiragana alphabet!"
        break
      end
    end
  end
end

t2 = Test2.new


On Wednesday, 15 April 2015 15:18:05 UTC-3, Cristiano de Araujo Bezerra 
wrote:
>
> i need some help. i tried a lot of time using loops but i cannot figure
> it out wha i want.
>
> is basicaly this:
>
> i type a letter and i have the output in hiragana but the program can´t
> finish untill i press 'q' and if type another letter it joins to the
> first...
>
> this is my code to start..
>
>
> this way i can enter a letter and get a hirana equivalent
> but when it happens the program stops!
>
>
> class Test
>   def initialize
>     vowels = Hash['a'=>'あ', 'i'=>'い', 'u'=>'う', 'e'=>'え', 'o'=>'お']
>     letter = gets.chomp.downcase
>     # logic here
>     case letter
>     when 'a'
>       print "#{vowels['a']}"
>     when 'i'
>       print "#{vowels['i']}"
>     when 'u'
>       print "#{vowels['u']}"
>     when 'e'
>       print "#{vowels['e']}"
>     when 'o'
>       print "#{vowels['o']}"
>     else
>       puts "This letter is not part of hiragana alphabet!"
>     end
>   end
> end
>
> t = Test.new
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5a54f028-d3d2-4251-beb8-64a6c44da80f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to