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

Attributes

color[RW]
stop[RW]

Public Class Methods

color_to_s(c) click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 203
def self.color_to_s(c)
  if c.is_a?(Sass::Script::Value::String)
    c.value.dup
  else
    c.inspect.dup
  end
end
color_to_svg_alpha(c) click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 191
def self.color_to_svg_alpha(c)
  # svg doesn't support the "transparent" keyword; we need to manually
  # refactor it into "transparent black"
  if c.is_a?(Sass::Script::Value::String) && c.value == "transparent"
    0
  elsif c.is_a?(Sass::Script::Value::String) && c.value == "currentColor"
    1
  else
    c.alpha
  end
end
color_to_svg_s(c) click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 179
def self.color_to_svg_s(c)
  # svg doesn't support the "transparent" keyword; we need to manually
  # refactor it into "transparent black"
  if c.is_a?(Sass::Script::Value::String) && c.value == "transparent"
    "black"
  elsif c.is_a?(Sass::Script::Value::String)
    c.value.dup
  else
    self.color_to_s(c.with(:alpha => 1))
  end
end
new(color, stop = nil) click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 152
def initialize(color, stop = nil)
  assert_legal_color! color
  assert_legal_color_stop! stop if stop
  self.color, self.stop = color, stop
end

Public Instance Methods

children() click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 149
def children
  [color, stop].compact
end
inspect() click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 157
def inspect
  to_s
end
to_s(options = self.options) click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 211
def to_s(options = self.options)
  s = self.class.color_to_s(color)
  if stop
    s << " "
    if stop.respond_to?(:unitless?) && stop.unitless?
      s << stop.times(number(100, "%")).inspect
    else
      s << stop.to_s
    end
  end
  s
end
to_sass(options = nil) click to toggle source
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 224
def to_sass(options = nil)
  identifier("color-stop(#{color.to_sass rescue nil}, #{stop.to_sass rescue nil})")
end