Class: Sass::Media::QueryList
- Inherits:
-
Object
- Object
- Sass::Media::QueryList
- Defined in:
- lib/sass/media.rb
Overview
A comma-separated list of queries.
media_query [ ',' S* media_query ]*
Instance Attribute Summary collapse
-
#queries ⇒ Array<Query>
The queries contained in this list.
Instance Method Summary collapse
-
#deep_copy ⇒ QueryList
Returns a deep copy of this query list and all its children.
-
#initialize(queries) ⇒ QueryList
constructor
A new instance of QueryList.
-
#merge(other) ⇒ QueryList?
Merges this query list with another.
-
#to_a ⇒ Array<String, Sass::Script::Tree::Node>
Returns a representation of the query as an array of strings and potentially Script::Tree::Nodes (if there's interpolation in it).
-
#to_css ⇒ String
Returns the CSS for the media query list.
-
#to_src(options) ⇒ String
Returns the Sass/SCSS code for the media query list.
Constructor Details
#initialize(queries) ⇒ QueryList
Returns a new instance of QueryList.
13 14 15 |
# File 'lib/sass/media.rb', line 13
def initialize(queries)
@queries = queries
end
|
Instance Attribute Details
#queries ⇒ Array<Query>
The queries contained in this list.
10 11 12 |
# File 'lib/sass/media.rb', line 10
def queries
@queries
end
|
Instance Method Details
#deep_copy ⇒ QueryList
Returns a deep copy of this query list and all its children.
58 59 60 |
# File 'lib/sass/media.rb', line 58
def deep_copy
QueryList.new(queries.map {|q| q.deep_copy})
end
|
#merge(other) ⇒ QueryList?
Merges this query list with another. The returned query list queries for the intersection between the two inputs.
Both query lists should be resolved.
24 25 26 27 28 |
# File 'lib/sass/media.rb', line 24
def merge(other)
new_queries = queries.map {|q1| other.queries.map {|q2| q1.merge(q2)}}.flatten.compact
return if new_queries.empty?
QueryList.new(new_queries)
end
|
#to_a ⇒ Array<String, Sass::Script::Tree::Node>
Returns a representation of the query as an array of strings and potentially Script::Tree::Nodes (if there's interpolation in it). When the interpolation is resolved and the strings are joined together, this will be the string representation of this query.
51 52 53 |
# File 'lib/sass/media.rb', line 51
def to_a
Sass::Util.intersperse(queries.map {|q| q.to_a}, ', ').flatten
end
|
#to_css ⇒ String
Returns the CSS for the media query list.
33 34 35 |
# File 'lib/sass/media.rb', line 33
def to_css
queries.map {|q| q.to_css}.join(', ')
end
|
#to_src(options) ⇒ String
Returns the Sass/SCSS code for the media query list.
41 42 43 |
# File 'lib/sass/media.rb', line 41
def to_src(options)
queries.map {|q| q.to_src(options)}.join(', ')
end
|