Class: Cataract::ImportStatement Private
- Inherits:
-
Struct
- Object
- Struct
- Cataract::ImportStatement
- Defined in:
- lib/cataract/import_statement.rb,
lib/cataract/import_statement.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a CSS @import statement
They can later be resolved by the ImportResolver to fetch and inline the imported CSS.
Per CSS spec, @import must appear before all rules except @charset and @layer. Any @import that appears after a style rule is invalid and will be ignored with a warning.
Instance Attribute Summary collapse
-
#id ⇒ Integer
The import's position in the source (0-indexed).
-
#media ⇒ String?
The media query string (e.g., "print", "screen and (max-width: 768px)"), or nil.
-
#media_query_id ⇒ Integer?
The MediaQuery ID, or nil if no media query.
-
#resolved ⇒ Boolean
Whether this import has been resolved/processed.
-
#url ⇒ String
The URL to import (without quotes or url() wrapper).
Class Method Summary collapse
-
.make(id:, url:, media: nil, media_query_id: nil, resolved: false) ⇒ ImportStatement
private
Factory method for creating ImportStatement in tests.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
private
Compare two ImportStatement objects for equality.
-
#hash ⇒ Integer
private
Generate hash code for ImportStatement.
Instance Attribute Details
#id ⇒ Integer
The import's position in the source (0-indexed)
25 26 27 |
# File 'lib/cataract/import_statement.rb', line 25 def id @id end |
#media ⇒ String?
The media query string (e.g., "print", "screen and (max-width: 768px)"), or nil
25 26 27 |
# File 'lib/cataract/import_statement.rb', line 25 def media @media end |
#media_query_id ⇒ Integer?
The MediaQuery ID, or nil if no media query
25 26 27 |
# File 'lib/cataract/import_statement.rb', line 25 def media_query_id @media_query_id end |
#resolved ⇒ Boolean
Whether this import has been resolved/processed
25 26 27 |
# File 'lib/cataract/import_statement.rb', line 25 def resolved @resolved end |
#url ⇒ String
The URL to import (without quotes or url() wrapper)
25 26 27 |
# File 'lib/cataract/import_statement.rb', line 25 def url @url end |
Class Method Details
.make(id:, url:, media: nil, media_query_id: nil, resolved: false) ⇒ ImportStatement
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Factory method for creating ImportStatement in tests. Uses keyword arguments to avoid positional parameter confusion.
46 47 48 |
# File 'lib/cataract/import_statement.rb', line 46 def self.make(id:, url:, media: nil, media_query_id: nil, resolved: false) new(id, url, media, media_query_id, resolved) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Compare two ImportStatement objects for equality. Two imports are equal if they have the same URL and media query. The import ID is ignored as it's an implementation detail.
56 57 58 59 60 61 |
# File 'lib/cataract/import_statement.rb', line 56 def ==(other) return false unless other.is_a?(ImportStatement) # Compare by media string (for unparsed imports) or media_query_id (for resolved imports) url == other.url && media == other.media end |
#hash ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate hash code for ImportStatement. Uses URL and media string (ignores import ID position).
69 70 71 |
# File 'lib/cataract/import_statement.rb', line 69 def hash [url, media].hash end |