Class: CssCompare::CSS::Value::Literal

Inherits:
Base
  • Object
show all
Defined in:
lib/css_compare/css/value/literal.rb

Overview

Wraps the SassScript Literal object.

Instance Attribute Summary

Attributes inherited from Base

#value

Instance Method Summary collapse

Methods inherited from Base

#important?, #initialize, #to_s

Constructor Details

This class inherits a constructor from CssCompare::CSS::Value::Base

Instance Method Details

#==(other) ⇒ Boolean

Checks, whether two literals are equal.

Parameters:

  • other (Literal)

    the other literal

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/css_compare/css/value/literal.rb', line 11

def ==(other)
  if color?
    return false unless other.color?
    ::Color.equivalent?(color, other.color)
  else
    return false unless super
    value1 = sanitize_string(@value.to_sass)
    value2 = sanitize_string(other.value.to_sass)
    value1 == value2
  end
end

#colorObject



33
34
35
36
# File 'lib/css_compare/css/value/literal.rb', line 33

def color
  return nil unless color?
  hex_color? ? hex_color : named_color
end

#color?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/css_compare/css/value/literal.rb', line 29

def color?
  named_color? || hex_color?
end

#equals?(other) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/css_compare/css/value/literal.rb', line 23

def equals?(other)
  value1 = sanitize_font(@value.to_sass)
  value2 = sanitize_font(other.value.to_sass)
  value1 == value2
end