class SassC::Script::Value::Color

def alpha_string

and rounded to 8 decimal places.
Returns the alpha value of this color as a string
def alpha_string
  alpha.round(8).to_s
end

def eql?(other_color)

True if this Color is equal to `other_color`
def eql?(other_color)
  unless other_color.is_a?(self.class)
    raise ArgumentError, "No implicit conversion of #{other_color.class} to #{self.class}"
  end
  self.value == other_color.value
end

def hash

This method is used internally by the Hash class and is not the same as `.to_h`
Returns a numeric value for comparing two Color objects
def hash
  value.hash
end

def hlsa?

True if this color has HSLA values
def hlsa?
  @mode == :hlsa
end

def initialize(red:nil, green:nil, blue:nil, hue:nil, saturation:nil, lightness:nil, alpha:1.0)

values, plus an optional `alpha` transparency value.
Creates a new color with (`red`, `green`, `blue`) or (`hue`, `saturation`, `lightness`
def initialize(red:nil, green:nil, blue:nil, hue:nil, saturation:nil, lightness:nil, alpha:1.0)
  if red && green && blue && alpha
    @mode = :rgba
    @red = SassC::Util.clamp(red.to_i, 0, 255)
    @green = SassC::Util.clamp(green.to_i, 0, 255)
    @blue = SassC::Util.clamp(blue.to_i, 0, 255)
    @alpha = SassC::Util.clamp(alpha.to_f, 0.0, 1.0)
  elsif hue && saturation && lightness && alpha
    @mode = :hsla
    @hue = SassC::Util.clamp(hue.to_i, 0, 360)
    @saturation = SassC::Util.clamp(saturation.to_i, 0, 100)
    @lightness = SassC::Util.clamp(lightness.to_i, 0, 100)
    @alpha = SassC::Util.clamp(alpha.to_f, 0.0, 1.0)
  else
    raise SassC::UnsupportedValue, "Unable to determine color configuration for "
  end
end

def rgba?

True if this color has RGBA values
def rgba?
  @mode == :rgba
end

def to_s

`rgb(…)`, `rgba(…)`, `hsl(…)`, or `hsla(…)`.
Returns a CSS color declaration in the form
def to_s
  if rgba? && @alpha == 1.0
    return "rgb(#{@red}, #{@green}, #{@blue})"
  elsif rgba?
    return "rgba(#{@red}, #{@green}, #{@blue}, #{alpha_string})"
  elsif hsla? && @alpha == 1.0
    return "hsl(#{@hue}, #{@saturation}%, #{@lightness}%)"
  else # hsla?
    return "hsla(#{@hue}, #{@saturation}%, #{@lightness}%, #{alpha_string})"
  end
end

def value

Provided for compatibility between different SassC::Script::Value classes
Returns the values of this color in an array.
def value
  return [
    red, green, blue,
    hue, saturation, lightness,
    alpha,
  ].compact
end