Class: Sass::Media::QueryList

Inherits:
Object
  • Object
show all
Defined in:
/Users/ceppstei/Projects/sass-lang/.sass/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

- (QueryList) initialize(queries)

Returns a new instance of QueryList

Parameters:



13
14
15
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/media.rb', line 13

def initialize(queries)
  @queries = queries
end

Instance Attribute Details

- (Array<Query>) queries

The queries contained in this list.

Returns:



10
11
12
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/media.rb', line 10

def queries
  @queries
end

Instance Method Details

- (QueryList) deep_copy

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

Returns:



58
59
60
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/media.rb', line 58

def deep_copy
  QueryList.new(queries.map {|q| q.deep_copy})
end

- (QueryList?) merge(other)

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 '/Users/ceppstei/Projects/sass-lang/.sass/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

- (Array<String, Sass::Script::Tree::Node>) to_a

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 '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/media.rb', line 51

def to_a
  Sass::Util.intersperse(queries.map {|q| q.to_a}, ', ').flatten
end

- (String) to_css

Returns the CSS for the media query list.

Returns:

  • (String)


33
34
35
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/media.rb', line 33

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

- (String) to_src(options)

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 '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/media.rb', line 41

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