class Riffer::Rig::Terminal::Theme
Attributes
bool
@dynamic enabled
Public Class Methods
(Riffer::Rig::Terminal::_Output io, ?no_color: bool) → Riffer::Rig::Terminal::Theme
Source
# File lib/riffer/rig/terminal/theme.rb, line 19 def self.for(io, no_color: false) new(enabled: io.tty? && !no_color) end
@rbs io: Riffer::Rig::Terminal::_Output @rbs no_color: bool @rbs return: Riffer::Rig::Terminal::Theme
(enabled: bool) → void
Source
# File lib/riffer/rig/terminal/theme.rb, line 11 def initialize(enabled:) @enabled = enabled freeze end
@rbs enabled: bool @rbs return: void
Public Instance Methods
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 46 def blue(text) = paint(text, Riffer::Rig::Terminal::Palette::BLUE)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 70 def bold(text) return text unless enabled "\e[1m#{text}\e[0m" end
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 98 def code(text) = cyan(text)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 50 def cyan(text) = paint(text, Riffer::Rig::Terminal::Palette::CYAN)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 62 def dim(text) return text unless enabled "\e[2m#{text}\e[0m" end
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 54 def grey(text) = paint(text, Riffer::Rig::Terminal::Palette::GREY)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 94 def heading(text) = bold(purple(text))
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 78 def italic(text) return text unless enabled "\e[3m#{text}\e[0m" end
@rbs text: String @rbs return: String
(String text, String url) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 103 def link(text, url) return text unless enabled "\e]8;;#{url}\e\\#{underline(blue(text))}\e]8;;\e\\" end
@rbs text: String @rbs url: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 38 def magenta(text) = paint(text, Riffer::Rig::Terminal::Palette::MAGENTA)
@rbs text: String @rbs return: String
(String text, Array[Integer] rgb) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 26 def paint(text, rgb) return text unless enabled "\e[38;2;#{rgb[0]};#{rgb[1]};#{rgb[2]}m#{text}\e[0m" end
@rbs text: String @rbs rgb: Array @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 34 def pink(text) = paint(text, Riffer::Rig::Terminal::Palette::PINK)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 42 def purple(text) = paint(text, Riffer::Rig::Terminal::Palette::PURPLE)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 58 def red(text) = paint(text, Riffer::Rig::Terminal::Palette::RED)
@rbs text: String @rbs return: String
(String text) → String
Source
# File lib/riffer/rig/terminal/theme.rb, line 86 def underline(text) return text unless enabled "\e[4m#{text}\e[0m" end
@rbs text: String @rbs return: String