class Mosespa::Puts
Public Class Methods
new(colorize)
click to toggle source
# File lib/m.rb, line 89 def initialize(colorize) @colorize = colorize @colors = Hash.new @available_colors = Queue.new String.colors .select{ |c| not [:black, :light_black, :white].include? c} .each { |c| @available_colors.push c } end
Public Instance Methods
puts(author, text)
click to toggle source
# File lib/m.rb, line 98 def puts(author, text) if @colorize unless @colors.has_key? author a_color = @available_colors.pop @colors[author] = a_color end c = @colors[author] author = author.colorize( c ) end $stdout.puts "#{author}: #{text}" end