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 152 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 148 def children [color_stops, position_or_angle].compact end
supports?(aspect)
click to toggle source
Calls superclass method
Compass::SassExtensions::Functions::GradientSupport::Gradient#supports?
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 171 def supports?(aspect) # I don't know how to support degree-based gradients in old webkit gradients (owg) or svg so we just disable them. if %w(owg svg).include?(aspect) && position_or_angle.is_a?(Sass::Script::Number) && position_or_angle.numerator_units.include?("deg") false else super end end
to_css2(options = self.options)
click to toggle source
# File lib/compass/sass_extensions/functions/gradient_support.rb, line 200 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 181 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 194 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 160 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 190 def to_svg(options = self.options) linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top")) end