class Warg::Console::SelectGraphicRendition
Constants
- BACKGROUND_COLORS
- EFFECTS
- RESET
- TEXT_COLORS
Public Class Methods
new(text_color: "0", background_color: "0", effect: "0")
click to toggle source
# File lib/warg.rb, line 504 def initialize(text_color: "0", background_color: "0", effect: "0") @text_color = TEXT_COLORS.fetch(text_color.to_s, text_color) @background_color = BACKGROUND_COLORS.fetch(background_color.to_s, background_color) @effect = EFFECTS.fetch(effect.to_s, effect) end
Public Instance Methods
call(text)
click to toggle source
# File lib/warg.rb, line 510 def call(text) "#{self}#{text}#{RESET}" end
modify(**attrs)
click to toggle source
# File lib/warg.rb, line 518 def modify(**attrs) combination = to_h.merge(attrs) do |key, old_value, new_value| if old_value == "0" new_value elsif new_value == "0" old_value else new_value end end self.class.new(**combination) end
to_h()
click to toggle source
# File lib/warg.rb, line 544 def to_h { text_color: @text_color, background_color: @background_color, effect: @effect } end
to_s()
click to toggle source
# File lib/warg.rb, line 540 def to_s to_str end
to_str()
click to toggle source
# File lib/warg.rb, line 536 def to_str "\e[#{@background_color};#{@effect};#{@text_color}m" end
wrap(text)
click to toggle source
# File lib/warg.rb, line 514 def wrap(text) call(text) end
|(other)
click to toggle source
# File lib/warg.rb, line 532 def |(other) modify(**other.to_h) end