Module: Paintbrush

Defined in:
lib/paintbrush.rb

Overview

Colorizes a string, provides ‘#paintbrush`. When included/extended in a class, call `#paintbrush` and pass a block to use the provided dynamically defined methods, e.g.:

“‘ruby class Foo

include Paintbrush

def bar
  puts paintbrush { cyan("hello #{green("there")}) }
end

“‘

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure {|PaintbrushSupport::Configuration| ... } ⇒ Object



29
30
31
# File 'lib/paintbrush.rb', line 29

def self.configure
  yield PaintbrushSupport::Configuration
end

.paintbrush(colorize: nil, &block) ⇒ Object



25
26
27
# File 'lib/paintbrush.rb', line 25

def self.paintbrush(colorize: nil, &block)
  PaintbrushSupport::ColorizedString.new(colorize: colorize, &block).colorized
end

.with_configuration(**options, &block) ⇒ Object



33
34
35
# File 'lib/paintbrush.rb', line 33

def self.with_configuration(**options, &block)
  PaintbrushSupport::Configuration.with_configuration(**options, &block)
end

Instance Method Details

#paintbrush(colorize: nil, &block) ⇒ Object



37
38
39
# File 'lib/paintbrush.rb', line 37

def paintbrush(colorize: nil, &block)
  Paintbrush.paintbrush(colorize: colorize, &block)
end