Class: Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Inherits:
-
Sass::Script::Literal
- Object
- Sass::Script::Literal
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Defined in:
- lib/compass/sass_extensions/functions/gradient_support.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#stop ⇒ Object
Returns the value of attribute stop.
Class Method Summary collapse
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(color, stop = nil) ⇒ ColorStop
constructor
A new instance of ColorStop.
- #inspect ⇒ Object
- #to_s(options = self.options) ⇒ Object
Constructor Details
#initialize(color, stop = nil) ⇒ ColorStop
Returns a new instance of ColorStop.
10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
6 7 8 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 6 def color @color end |
#stop ⇒ Object
Returns the value of attribute stop.
6 7 8 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 6 def stop @stop end |
Class Method Details
Instance Method Details
#children ⇒ Object
7 8 9 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 7 def children [color, stop].compact end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 21 def inspect to_s end |
#to_s(options = self.options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 32 def to_s( = self.) 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 |