Class: Cataract::AtRule
- Inherits:
-
Struct
- Object
- Struct
- Cataract::AtRule
- Defined in:
- lib/cataract/at_rule.rb,
lib/cataract/at_rule.rb
Instance Attribute Summary collapse
-
#conditional_group_id ⇒ Object
Returns the value of attribute conditional_group_id.
-
#content ⇒ Object
Returns the value of attribute content.
-
#id ⇒ Object
Returns the value of attribute id.
-
#media_query_id ⇒ Object
Returns the value of attribute media_query_id.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#specificity ⇒ Object
Returns the value of attribute specificity.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compare at-rules for logical equality based on CSS semantics.
-
#at_rule? ⇒ Boolean
Check if this is an at-rule.
-
#at_rule_type?(type) ⇒ Boolean
Check if this is a specific at-rule type.
-
#has_important?(_property = nil) ⇒ Boolean
Check if this at-rule has any !important declarations.
-
#has_property?(_property, _value = nil) ⇒ Boolean
Check if this at-rule has a declaration with the specified property.
-
#selector? ⇒ Boolean
Check if this is a selector-based rule (vs an at-rule like @keyframes).
Instance Attribute Details
#conditional_group_id ⇒ Object
Returns the value of attribute conditional_group_id
33 34 35 |
# File 'lib/cataract/at_rule.rb', line 33 def conditional_group_id @conditional_group_id end |
#content ⇒ Object
Returns the value of attribute content
33 34 35 |
# File 'lib/cataract/at_rule.rb', line 33 def content @content end |
#id ⇒ Object
Returns the value of attribute id
33 34 35 |
# File 'lib/cataract/at_rule.rb', line 33 def id @id end |
#media_query_id ⇒ Object
Returns the value of attribute media_query_id
33 34 35 |
# File 'lib/cataract/at_rule.rb', line 33 def media_query_id @media_query_id end |
#selector ⇒ Object
Returns the value of attribute selector
33 34 35 |
# File 'lib/cataract/at_rule.rb', line 33 def selector @selector end |
#specificity ⇒ Object
Returns the value of attribute 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.
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.
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.
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.
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.
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).
40 41 42 |
# File 'lib/cataract/at_rule.rb', line 40 def selector? false end |