Class: Sass::Media::QueryList

Inherits:
Object
  • Object
show all
Defined in:
lib/sass/media.rb

Overview

A comma-separated list of queries.

media_query [ ',' S* media_query ]*

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queries) ⇒ QueryList

Returns a new instance of QueryList.

Parameters:



13
14
15
# File 'lib/sass/media.rb', line 13

def initialize(queries)
  @queries = queries
end

Instance Attribute Details

#queriesArray<Query>

The queries contained in this list.

Returns:



10
11
12
# File 'lib/sass/media.rb', line 10

def queries
  @queries
end

Instance Method Details

#deep_copyQueryList

Returns a deep copy of this query list and all its children.

Returns:



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.

Parameters:

Returns:

  • (QueryList?)

    The merged list, or nil if there is no intersection.



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_aArray<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.

Returns:



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_cssString

Returns the CSS for the media query list.

Returns:

  • (String)


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.

Parameters:

  • options ({Symbol => Object})

    An options hash (see CSS#initialize).

Returns:

  • (String)


41
42
43
# File 'lib/sass/media.rb', line 41

def to_src(options)
  queries.map {|q| q.to_src(options)}.join(', ')
end