Class: Cataract::ConditionalGroup
- Inherits:
-
Struct
- Object
- Struct
- Cataract::ConditionalGroup
- Defined in:
- lib/cataract/conditional_group.rb
Overview
ConditionalGroup represents a CSS "conditional group" at-rule wrapper - @supports, @layer, @container, or @scope.
Like MediaQuery, these are stored in the Stylesheet and referenced by Rules/AtRules via conditional_group_id, so the rules they wrap stay flat and queryable in Stylesheet#rules while the wrapper's own name/condition (and nesting inside other conditional groups, via parent_id) survive for round-trip serialization. Cataract never evaluates the condition/name (no feature-query or container-query matching) - it's kept as opaque text.
Instance Attribute Summary collapse
-
#condition ⇒ String?
Opaque condition/prelude text (feature query, container query, scope root/limit), nil if none.
-
#id ⇒ Integer
Unique identifier for this conditional group within the stylesheet.
-
#name ⇒ String?
Named form (e.g.
@layer utilities,@container sidebar), nil if unnamed. -
#parent_id ⇒ Integer?
Id of the enclosing ConditionalGroup, or nil if not nested inside another one.
-
#type ⇒ Symbol
At-rule kind (:supports, :layer, :container, :scope).
Class Method Summary collapse
-
.make(id:, type:, name: nil, condition: nil, parent_id: nil) ⇒ ConditionalGroup
Create a ConditionalGroup with keyword arguments for readability.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compare conditional groups for equality based on type, name, condition, and nesting.
-
#hash ⇒ Integer
Generate hash code for this conditional group.
-
#inspect ⇒ String
Get detailed inspection string.
Instance Attribute Details
#condition ⇒ String?
Opaque condition/prelude text (feature query, container query, scope root/limit), nil if none
26 27 28 |
# File 'lib/cataract/conditional_group.rb', line 26 def condition @condition end |
#id ⇒ Integer
Unique identifier for this conditional group within the stylesheet
26 27 28 |
# File 'lib/cataract/conditional_group.rb', line 26 def id @id end |
#name ⇒ String?
Named form (e.g. @layer utilities, @container sidebar), nil if unnamed
26 27 28 |
# File 'lib/cataract/conditional_group.rb', line 26 def name @name end |
#parent_id ⇒ Integer?
Id of the enclosing ConditionalGroup, or nil if not nested inside another one
26 27 28 |
# File 'lib/cataract/conditional_group.rb', line 26 def parent_id @parent_id end |
#type ⇒ Symbol
At-rule kind (:supports, :layer, :container, :scope)
26 27 28 |
# File 'lib/cataract/conditional_group.rb', line 26 def type @type end |
Class Method Details
.make(id:, type:, name: nil, condition: nil, parent_id: nil) ⇒ ConditionalGroup
Create a ConditionalGroup with keyword arguments for readability.
38 39 40 |
# File 'lib/cataract/conditional_group.rb', line 38 def self.make(id:, type:, name: nil, condition: nil, parent_id: nil) new(id, type, name, condition, parent_id) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compare conditional groups for equality based on type, name, condition, and nesting. IDs are not considered since they're internal identifiers.
47 48 49 50 51 52 53 54 |
# File 'lib/cataract/conditional_group.rb', line 47 def ==(other) case other when ConditionalGroup type == other.type && name == other.name && condition == other.condition else false end end |
#hash ⇒ Integer
Generate hash code for this conditional group.
60 61 62 |
# File 'lib/cataract/conditional_group.rb', line 60 def hash [self.class, type, name, condition].hash end |
#inspect ⇒ String
Get detailed inspection string.
67 68 69 70 |
# File 'lib/cataract/conditional_group.rb', line 67 def inspect "#<ConditionalGroup id=#{id} type=#{type.inspect} name=#{name.inspect} " \ "condition=#{condition.inspect} parent_id=#{parent_id.inspect}>" end |