書きかけで放置していたのを完成させました class HQ9Plus def initialize(source) @source = source @count = 0 end def run @source.each_char do |c| case c when "H" hello when "Q" source when "9" bottles when "+" count end end end private def hello puts "Hello World" end def source puts @source end def count @count += 1 end def bottles 99.downto(0) do |i| beforeBottles = "#{i} bottle" afterBottles = "#{i-1} bottle" action