Basic Usage of Pastel
masterPastel provides an intuitive API for styling strings without monkey-patching the String class. It returns a colored string rather than printing it, so you must call puts or another output method yourself.
Basic coloring:
pastel = Pastel.new
puts pastel.red("Unicorns!")Chainable styles:
pastel.red.on_green.bold("Unicorns!")Combining styled and unstyled strings:
pastel.red("Unicorns") + " will rule " + pastel.green("the World!")Passing multiple arguments:
pastel.red("Unicorns", "are", "running", "everywhere!")Nesting styles:
pastel.red("Unicorns ", pastel.on_green("everywhere!"))Nesting using blocks:
pastel.red.on_green("Unicorns") {
green.on_red("will ", "dominate") {
yellow("the world!")
}
}pastel = Pastel.new
puts pastel.red("Unicorns!")