Class: CssCompare::CSS::Component::MarginBox

Inherits:
Selector
  • Object
show all
Defined in:
lib/css_compare/css/component/margin_box.rb

Overview

Represents a @page’s margin box declaration. A page margin box consists of a margin symbol, like ‘@top-left-corner` and a list of declarations.

MarginBox inherits from the Selector class, since there are inevitable similarities. The specified margin symbol can be reached by the value property of the instance of this class.

See Also:

Constant Summary collapse

IGNORED_CONDITIONS =
%w(width height aspect-ratio orientation).freeze

Instance Attribute Summary

Attributes inherited from Selector

#name, #properties

Instance Method Summary collapse

Methods inherited from Selector

#==, #deep_copy, #initialize, #merge, #to_json

Methods inherited from Base

#==, #equals?

Constructor Details

This class inherits a constructor from CssCompare::CSS::Component::Selector

Instance Method Details

#add_property(prop, deep_copy = false) ⇒ Object

Looks for a size property to delete the values that should be ignored according to the @page W3 specification.

If a size property declaration is qualified by a ‘width’, ‘height’, ‘device-width’, ‘device-height’, ‘aspect-ratio’, ‘device-aspect-ratio’ or ‘orientation’ media query (or other conditional on the size of the paper), then the declaration must be ignored.

See Also:



31
32
33
34
35
36
# File 'lib/css_compare/css/component/margin_box.rb', line 31

def add_property(prop, deep_copy = false)
  prop.values.delete_if do |k, _|
    IGNORED_CONDITIONS.any? { |condition| k.include?(condition) }
  end if prop.name == 'size'
  super(prop, deep_copy)
end