Class: CssCompare::CSS::Value::Function
- Defined in:
- lib/css_compare/css/value/function.rb
Overview
Wraps the SassScript Funcall object
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Checks, whether two function expressions are equal.
- #alpha ⇒ Object
- #alpha? ⇒ Boolean
- #color ⇒ Object
- #color? ⇒ Boolean
Methods inherited from Base
#equals?, #important?, #initialize, #to_s
Constructor Details
This class inherits a constructor from CssCompare::CSS::Value::Base
Instance Method Details
#==(other) ⇒ Boolean
Checks, whether two function expressions are equal.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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 ⇒ Object
45 46 47 48 |
# File 'lib/css_compare/css/value/function.rb', line 45 def alpha return @value.args[3] if alpha? false end |
#alpha? ⇒ Boolean
41 42 43 |
# File 'lib/css_compare/css/value/function.rb', line 41 def alpha? @value.args.length == 4 end |
#color ⇒ Object
31 32 33 34 35 36 37 38 39 |
# 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? ⇒ Boolean
27 28 29 |
# File 'lib/css_compare/css/value/function.rb', line 27 def color? rgb? || hsl? end |