class CssCompare::CSS::Value::Function
Wraps the SassScript Funcall object
Constants
- HSL_COLOR_FUNCTIONS
- RGB_COLOR_FUNCTIONS
Public Instance Methods
==(other)
click to toggle source
Checks, whether two function expressions are equal.
@param [Function] other the other function expression @return [Boolean]
Calls superclass method
CssCompare::CSS::Value::Base#==
# File lib/css_compare/css/value/function.rb, line 11 def ==(other) if color? return false unless other.color? ::Color.equivalent?(color, other.color) else return false unless super arg1 = @value.args.length arg2 = other.value.args.length return false unless arg1 == arg2 args1 = @value.args.collect { |x| ValueFactory.create(x) } args2 = other.value.args.collect { |x| ValueFactory.create(x) } args1.each_index { |i| args1[i] == args2[i] } end end
alpha()
click to toggle source
# File lib/css_compare/css/value/function.rb, line 45 def alpha return @value.args[3] if alpha? false end
alpha?()
click to toggle source
# File lib/css_compare/css/value/function.rb, line 41 def alpha? @value.args.length == 4 end
color()
click to toggle source
# File lib/css_compare/css/value/function.rb, line 31 def color raise StandardError, 'Function not a color' unless color? args = @value.args.collect { |x| x.value.value } if rgb? ::Color::RGB.new(args[0], args[1], args[2]) elsif hsl? ::Color::HSL.new(args[0], args[1], args[2]) end end
color?()
click to toggle source
@see Base#color?
# File lib/css_compare/css/value/function.rb, line 27 def color? rgb? || hsl? end
Private Instance Methods
hsl?()
click to toggle source
# File lib/css_compare/css/value/function.rb, line 59 def hsl? HSL_COLOR_FUNCTIONS.include?(@value.name) end
rgb?()
click to toggle source
# File lib/css_compare/css/value/function.rb, line 55 def rgb? RGB_COLOR_FUNCTIONS.include?(@value.name) end