class Apropos::MediaQuery

MediaQuery wraps a media query string with several features:

Attributes

query_list[R]
sort_value[R]

Public Class Methods

new(query_string, sort_value=0) click to toggle source
# File lib/apropos/media_query.rb, line 10
def initialize(query_string, sort_value=0)
  @query_list = query_string.split(',').map { |q| parenthesize(q.strip) }
  @sort_value = sort_value
end

Public Instance Methods

combine(other) click to toggle source
# File lib/apropos/media_query.rb, line 23
def combine(other)
  other_ql = other.query_list
  combo = query_list.map do |q|
    other_ql.map do |q2|
      "#{q} and #{q2}"
    end
  end.flatten
  self.class.new(combo.join(', '))
end
parenthesize(query) click to toggle source
# File lib/apropos/media_query.rb, line 15
def parenthesize(query)
  unless query =~ /^\(.+\)$/
    "(#{query})"
  else
    query
  end
end
to_css() click to toggle source
# File lib/apropos/media_query.rb, line 33
def to_css
  query_list.join(", ")
end
type() click to toggle source
# File lib/apropos/media_query.rb, line 37
def type
  "media"
end