Class: Applitools::PaddingBounds
- Inherits:
-
Object
- Object
- Applitools::PaddingBounds
- Defined in:
- lib/applitools/core/padding_bounds.rb
Constant Summary collapse
- ZERO_PADDING =
PaddingBounds.new(0, 0, 0, 0).freeze
- PIXEL_PADDING =
PaddingBounds.new(1, 1, 1, 1).freeze
Instance Attribute Summary collapse
-
#padding_bottom ⇒ Object
Returns the value of attribute padding_bottom.
-
#padding_left ⇒ Object
Returns the value of attribute padding_left.
-
#padding_right ⇒ Object
Returns the value of attribute padding_right.
-
#padding_top ⇒ Object
Returns the value of attribute padding_top.
Instance Method Summary collapse
-
#initialize(padding_left = nil, padding_top = nil, padding_right = nil, padding_bottom = nil, **kwargs) ⇒ PaddingBounds
constructor
A new instance of PaddingBounds.
- #to_hash ⇒ Object
- #zero? ⇒ Boolean
Constructor Details
#initialize(padding_left = nil, padding_top = nil, padding_right = nil, padding_bottom = nil, **kwargs) ⇒ PaddingBounds
Returns a new instance of PaddingBounds.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/applitools/core/padding_bounds.rb', line 7 def initialize(padding_left = nil, padding_top = nil, padding_right = nil, padding_bottom = nil, **kwargs) # Support both positional and keyword arguments if padding_left.nil? && !kwargs.empty? padding_left = kwargs[:left] || 0 padding_top = kwargs[:top] || 0 padding_right = kwargs[:right] || 0 padding_bottom = kwargs[:bottom] || 0 end Applitools::ArgumentGuard.is_a?(padding_left, 'padding_left', Integer) Applitools::ArgumentGuard.is_a?(padding_top, 'padding_top', Integer) Applitools::ArgumentGuard.is_a?(padding_right, 'padding_right', Integer) Applitools::ArgumentGuard.is_a?(padding_bottom, 'padding_bottom', Integer) Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_left, 'padding_left') Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_top, 'padding_top') Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_right, 'padding_right') Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_bottom, 'padding_bottom') self.padding_left = padding_left self.padding_top = padding_top self.padding_right = padding_right self.padding_bottom = padding_bottom end |
Instance Attribute Details
#padding_bottom ⇒ Object
Returns the value of attribute padding_bottom.
6 7 8 |
# File 'lib/applitools/core/padding_bounds.rb', line 6 def padding_bottom @padding_bottom end |
#padding_left ⇒ Object
Returns the value of attribute padding_left.
6 7 8 |
# File 'lib/applitools/core/padding_bounds.rb', line 6 def padding_left @padding_left end |
#padding_right ⇒ Object
Returns the value of attribute padding_right.
6 7 8 |
# File 'lib/applitools/core/padding_bounds.rb', line 6 def padding_right @padding_right end |
#padding_top ⇒ Object
Returns the value of attribute padding_top.
6 7 8 |
# File 'lib/applitools/core/padding_bounds.rb', line 6 def padding_top @padding_top end |
Instance Method Details
#to_hash ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/applitools/core/padding_bounds.rb', line 35 def to_hash { left: padding_left, top: padding_top, right: padding_right, bottom: padding_bottom } end |
#zero? ⇒ Boolean
44 45 46 |
# File 'lib/applitools/core/padding_bounds.rb', line 44 def zero? padding_left == 0 && padding_top == 0 && padding_right == 0 && padding_bottom == 0 end |