Module: CSS::MediaQueries::Evaluator
Overview
Evaluates a MediaQueryList against a Context, returning true if at least one media-query in the list matches.
Constant Summary collapse
- EM_PX =
Length conversion to CSS px assumes 1em = 1rem = 16px. Per Media Queries Level 4 ยง1.3 this is the conventional fallback when the font-size of the root is unknown.
16.0- LENGTH_UNITS_PX =
{ 'px' => 1.0, 'em' => EM_PX, 'rem' => EM_PX, 'ex' => EM_PX * 0.5, 'ch' => EM_PX * 0.5, 'pt' => 96.0 / 72, 'pc' => 16.0, 'in' => 96.0, 'cm' => 96.0 / 2.54, 'mm' => 96.0 / 25.4, 'q' => 96.0 / 25.4 / 4 }.freeze
- RESOLUTION_UNITS_DPPX =
{ 'dppx' => 1.0, 'x' => 1.0, 'dpi' => 1.0 / 96, 'dpcm' => 2.54 / 96 }.freeze
- RESOLUTION_FEATURES =
%w[resolution].freeze
- INVERSE_OP =
{lt: :gt, le: :ge, gt: :lt, ge: :le, eq: :eq}.freeze
- PREFIX_OP =
{min: :ge, max: :le}.freeze
Instance Method Summary collapse
Instance Method Details
#evaluate(query_list, context) ⇒ Object
40 41 42 |
# File 'lib/css/media_queries/evaluator.rb', line 40 def evaluate(query_list, context) query_list.queries.any? { evaluate_query(it, context) } end |