class Rainbow::Color::RGB

Attributes

b[R]
g[R]
r[R]

Public Class Methods

new(ground, *values) click to toggle source
Calls superclass method Rainbow::Color::Indexed::new
# File lib/rainbow/color.rb, line 102
def initialize(ground, *values)
  if values.min < 0 || values.max > 255
    fail ArgumentError, "RGB value outside 0-255 range"
  end

  super(ground, 8)
  @r, @g, @b = values
end
to_ansi_domain(value) click to toggle source
# File lib/rainbow/color.rb, line 98
def self.to_ansi_domain(value)
  (6 * (value / 256.0)).to_i
end

Public Instance Methods

codes() click to toggle source
Calls superclass method Rainbow::Color::Indexed#codes
# File lib/rainbow/color.rb, line 111
def codes
  super + [5, code_from_rgb]
end

Private Instance Methods

code_from_rgb() click to toggle source
# File lib/rainbow/color.rb, line 117
def code_from_rgb
  16 + self.class.to_ansi_domain(r) * 36 +
       self.class.to_ansi_domain(g) * 6  +
       self.class.to_ansi_domain(b)
end