Module: Kutils::FormatUtils
- Defined in:
- lib/utils/format_utils.rb
Overview
FormatUtils provides formatting helpers for markdown and colored text.
Class Method Summary collapse
-
.color_code(color) ⇒ Integer
Get ANSI color code.
-
.color_text(text, color) ⇒ String
Colorize text in terminal.
-
.markdown_title(title) ⇒ String
Format a markdown title.
Class Method Details
.color_code(color) ⇒ Integer
Get ANSI color code
28 29 30 |
# File 'lib/utils/format_utils.rb', line 28 def self.color_code(color) { red: 31, green: 32, yellow: 33, blue: 34 }[color] || 0 end |
.color_text(text, color) ⇒ String
Colorize text in terminal
21 22 23 |
# File 'lib/utils/format_utils.rb', line 21 def self.color_text(text, color) "\e[#{color_code(color)}m#{text}\e[0m" end |
.markdown_title(title) ⇒ String
Format a markdown title
13 14 15 |
# File 'lib/utils/format_utils.rb', line 13 def self.markdown_title(title) "# #{title}\n\n" end |