class Compass::SassExtensions::Functions::GradientSupport::LinearGradient

Attributes

color_stops[RW]
position_or_angle[RW]

Public Class Methods

new(position_or_angle, color_stops) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 143
def initialize(position_or_angle, color_stops)
  unless color_stops.value.size >= 2
    raise Sass::SyntaxError, "At least two color stops are required for a linear-gradient"
  end
  self.position_or_angle = position_or_angle
  self.color_stops = color_stops
end

Public Instance Methods

children() click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 139
def children
  [color_stops, position_or_angle].compact
end
to_css2(options = self.options) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 183
def to_css2(options = self.options)
  Sass::Script::String.new("")
end
to_owg(options = self.options) click to toggle source

Output the original webkit gradient syntax

# File lib/compass/sass_extensions/functions/gradient_support.rb, line 164
def to_owg(options = self.options)
  args = []
  args << grad_point(position_or_angle || Sass::Script::String.new("top"))
  args << linear_end_position(position_or_angle, color_stops)
  args << grad_color_stops(color_stops)
  args.each{|a| a.options = options}
  Sass::Script::String.new("-webkit-gradient(linear, #{args.join(', ')})")
end
to_pie(options = self.options) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 177
def to_pie(options = self.options)
  # PIE just uses the standard rep, but the property is prefixed so
  # the presence of this attribute helps flag when to render a special rule.
  Sass::Script::String.new to_s(options)
end
to_s(options = self.options) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 151
def to_s(options = self.options)
  s = "linear-gradient("
  s << position_or_angle.to_s(options) << ", " if position_or_angle
  s << color_stops.to_s(options)
  s << ")"
end
to_svg(options = self.options) click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 173
def to_svg(options = self.options)
  linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top"))
end