Class: Mosespa::Puts
- Inherits:
-
Object
- Object
- Mosespa::Puts
- Defined in:
- lib/m.rb
Instance Method Summary collapse
-
#initialize(colorize) ⇒ Puts
constructor
A new instance of Puts.
- #puts(author, text) ⇒ Object
Constructor Details
#initialize(colorize) ⇒ Puts
Returns a new instance of Puts.
88 89 90 91 92 93 94 95 |
# File 'lib/m.rb', line 88 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 |
Instance Method Details
#puts(author, text) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/m.rb', line 97 def puts(, text) if @colorize unless @colors.has_key? a_color = @available_colors.pop @colors[] = a_color end c = @colors[] = .colorize( c ) end $stdout.puts "#{}: #{text}" end |