Module: Ripl::Rc::Color::Imp

Included in:
U
Defined in:
lib/ripl/rc/color.rb

Instance Method Summary collapse

Instance Method Details

#black(&block) ⇒ Object



65
# File 'lib/ripl/rc/color.rb', line 65

def   black █ color(30, &block); end

#blue(&block) ⇒ Object



69
# File 'lib/ripl/rc/color.rb', line 69

def    blue █ color(34, &block); end

#color(rgb) ⇒ Object



61
62
63
# File 'lib/ripl/rc/color.rb', line 61

def color rgb
  "\x1b[#{rgb}m" + (block_given? ? "#{yield}#{reset}" : '')
end

#colorsObject



57
58
59
# File 'lib/ripl/rc/color.rb', line 57

def colors
  Ripl.config[:rc_color]
end

#cyan(&block) ⇒ Object



71
# File 'lib/ripl/rc/color.rb', line 71

def    cyan █ color(36, &block); end

#find_color(value) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/ripl/rc/color.rb', line 48

def find_color value
  (colors.sort{ |(k1, v1), (k2, v2)|
    # Class <=> Class
    if    k1 < k2 then -1
    elsif k1 > k2 then  1
    else                0
    end}.find{ |(klass, _)| value.kind_of?(klass) } || []).last
end

#green(&block) ⇒ Object



67
# File 'lib/ripl/rc/color.rb', line 67

def   green &block; color(32, &block); end

#magenta(&block) ⇒ Object



70
# File 'lib/ripl/rc/color.rb', line 70

def magenta &block; color(35, &block); end

#red(&block) ⇒ Object



66
# File 'lib/ripl/rc/color.rb', line 66

def     red &block; color(31, &block); end

#reset(&block) ⇒ Object



73
# File 'lib/ripl/rc/color.rb', line 73

def   reset &block; color('', &block); end

#white(&block) ⇒ Object



72
# File 'lib/ripl/rc/color.rb', line 72

def   white &block; color(37, &block); end

#yellow(&block) ⇒ Object



68
# File 'lib/ripl/rc/color.rb', line 68

def  yellow &block; color(33, &block); end