class Compass::SassExtensions::Functions::GradientSupport::ColorStop

Attributes

color[RW]
stop[RW]

Public Class Methods

color_to_s(c) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 24
def self.color_to_s(c)
  if c.is_a?(Sass::Script::String)
    c.value.dup
  else
    c.inspect.dup
  end
end
new(color, stop = nil) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 10
def initialize(color, stop = nil)
  unless Sass::Script::Color === color ||
         Sass::Script::Funcall === color ||
         (Sass::Script::String === color && color.value == "transparent")
    raise Sass::SyntaxError, "Expected a color. Got: #{color}"
  end
  if stop && !stop.is_a?(Sass::Script::Number)
    raise Sass::SyntaxError, "Expected a number. Got: #{stop}"
  end
  self.color, self.stop = color, stop
end

Public Instance Methods

children() click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 7
def children
  [color, stop].compact
end
inspect() click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 21
def inspect
  to_s
end
to_s(options = self.options) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 32
def to_s(options = self.options)
  s = self.class.color_to_s(color)
  if stop
    s << " "
    if stop.unitless?
      s << stop.times(Sass::Script::Number.new(100, ["%"])).inspect
    else
      s << stop.inspect
    end
  end
  s
end