Class: Cataract::AtRule

Inherits:
Struct
  • Object
show all
Defined in:
lib/cataract/at_rule.rb,
lib/cataract/at_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#conditional_group_idObject

Returns the value of attribute conditional_group_id

Returns:

  • (Object)

    the current value of conditional_group_id



33
34
35
# File 'lib/cataract/at_rule.rb', line 33

def conditional_group_id
  @conditional_group_id
end

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



33
34
35
# File 'lib/cataract/at_rule.rb', line 33

def content
  @content
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



33
34
35
# File 'lib/cataract/at_rule.rb', line 33

def id
  @id
end

#media_query_idObject

Returns the value of attribute media_query_id

Returns:

  • (Object)

    the current value of media_query_id



33
34
35
# File 'lib/cataract/at_rule.rb', line 33

def media_query_id
  @media_query_id
end

#selectorObject

Returns the value of attribute selector

Returns:

  • (Object)

    the current value of selector



33
34
35
# File 'lib/cataract/at_rule.rb', line 33

def selector
  @selector
end

#specificityObject

Returns the value of attribute specificity

Returns:

  • (Object)

    the current value of specificity



33
34
35
# File 'lib/cataract/at_rule.rb', line 33

def specificity
  @specificity
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Compare at-rules for logical equality based on CSS semantics.

Two at-rules are equal if they have the same selector and content. Internal implementation details (id) are not considered since they don't affect the CSS semantics.

Parameters:

  • other (Object)

    Object to compare with

Returns:

  • (Boolean)

    true if at-rules have same selector and content



91
92
93
94
95
96
# File 'lib/cataract/at_rule.rb', line 91

def ==(other)
  return false unless other.is_a?(AtRule)

  selector == other.selector &&
    content == other.content
end

#at_rule?Boolean

Check if this is an at-rule.

Returns:

  • (Boolean)

    Always returns true for AtRule objects



47
48
49
# File 'lib/cataract/at_rule.rb', line 47

def at_rule?
  true
end

#at_rule_type?(type) ⇒ Boolean

Check if this is a specific at-rule type.

Examples:

Check for @keyframes

at_rule.at_rule_type?(:keyframes) #=> true if selector is "@keyframes ..."

Check for @font-face

at_rule.at_rule_type?(:font_face) #=> true if selector is "@font-face"

Parameters:

  • type (Symbol)

    At-rule type (e.g., :keyframes, :font_face)

Returns:

  • (Boolean)

    true if at-rule matches the type



61
62
63
64
# File 'lib/cataract/at_rule.rb', line 61

def at_rule_type?(type)
  type_str = "@#{type.to_s.tr('_', '-')}"
  selector.start_with?(type_str)
end

#has_important?(_property = nil) ⇒ Boolean

Check if this at-rule has any !important declarations.

Parameters:

  • _property (String, nil) (defaults to: nil)

    Optional property name

Returns:

  • (Boolean)

    Always returns false for AtRule objects



79
80
81
# File 'lib/cataract/at_rule.rb', line 79

def has_important?(_property = nil)
  false
end

#has_property?(_property, _value = nil) ⇒ Boolean

Check if this at-rule has a declaration with the specified property.

Parameters:

  • _property (String)

    CSS property name

  • _value (String, nil) (defaults to: nil)

    Optional value to match

Returns:

  • (Boolean)

    Always returns false for AtRule objects



71
72
73
# File 'lib/cataract/at_rule.rb', line 71

def has_property?(_property, _value = nil)
  false
end

#selector?Boolean

Check if this is a selector-based rule (vs an at-rule like @keyframes).

Returns:

  • (Boolean)

    Always returns false for AtRule objects



40
41
42
# File 'lib/cataract/at_rule.rb', line 40

def selector?
  false
end