Class: Habaki::MediaQueryExpression
- Defined in:
- lib/habaki/media_rule.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ MediaQueryExpression
constructor
A new instance of MediaQueryExpression.
- #media_match?(media) ⇒ Boolean
- #read_from_katana(exp) ⇒ void private
- #string(format = Formatter::Base.new) ⇒ String
- #value ⇒ Value
Methods inherited from Node
Constructor Details
#initialize ⇒ MediaQueryExpression
Returns a new instance of MediaQueryExpression.
8 9 10 |
# File 'lib/habaki/media_rule.rb', line 8 def initialize @values = Values.new end |
Instance Attribute Details
Instance Method Details
#media_match?(media) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/habaki/media_rule.rb', line 19 def media_match?(media) case @feature when "min-width" return true unless media.width media.width >= value.to_px when "max-width" return true unless media.width media.width <= value.to_px when "min-height" return true unless media.height media.height >= value.to_px when "max-height" return true unless media.height media.height <= value.to_px end end |
#read_from_katana(exp) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
45 46 47 48 49 50 |
# File 'lib/habaki/media_rule.rb', line 45 def read_from_katana(exp) @feature = exp.feature if exp.values @values = Values.read_from_katana(exp.values) end end |
#string(format = Formatter::Base.new) ⇒ String
38 39 40 |
# File 'lib/habaki/media_rule.rb', line 38 def string(format = Formatter::Base.new) "(#{@feature}#{@values.any? ? ": #{@values.string(format)}" : ""})" end |