Skip to content

Welcome to Tech by Example

Menu
  • Home
  • Posts
  • System Design Questions
Menu

Print/Output color in the console in Ruby Language

Posted on August 13, 2021August 13, 2021 by admin

Overview

We can use the colorize gem for the same

https://github.com/fazibear/colorize

Just install the Gem

gem install colorize

Program

require 'colorize'

puts "Printing Blue Color".colorize(:blue)
puts "Printing Red Color".colorize(:red)
puts "Printing Yellow Color".colorize(:yellow)
puts "Printing Gree Color".colorize(:green)

Output

You can also check all color options by running the below code

puts String.colors 

It will output

black
light_black
red
light_red
green
light_green
yellow
light_yellow
blue
light_blue
magenta
light_magenta
cyan
light_cyan
white
light_white
default
©2025 Welcome to Tech by Example | Design: Newspaperly WordPress Theme