Class: IO

Inherits:
Object show all
Defined in:
lib/srs_game.rb

Instance Method Summary collapse

Instance Method Details

#rainbow_say(str, greeting_speed = 50) ⇒ Object



121
122
123
124
125
126
127
128
# File 'lib/srs_game.rb', line 121

def rainbow_say(str, greeting_speed = 50)
  colors = [:red, :yellow, :green, :cyan, :blue, :magenta].cycle

  str.each_line do |line|
    print (line =~ /\S/ ? line.__send__(colors.next) : line)
    sleep 1.0 / greeting_speed
  end
end