class HexaPDF::Layout::Style::Quad

A Quad holds four values and allows them to be accessed by the names top, right, bottom and left. Quads are normally used for holding values pertaining to boxes, like margins, paddings or borders.

Attributes

bottom[RW]

The value for bottom.

left[RW]

The value for left.

right[RW]

The value for right.

top[RW]

The value for top.

Public Class Methods

new(obj) click to toggle source

Creates a new Quad object. See set for more information.

# File lib/hexapdf/layout/style.rb, line 144
def initialize(obj)
  set(obj)
end

Public Instance Methods

set(value) click to toggle source
set(array)
set(quad)

Sets all values of the quad.

  • If a single value is provided that is neither a Quad nor an array, it is handled as if an array with one value was given.

  • If a Quad is provided, its values are used.

  • If an array is provided, it depends on the number of elemens in it:

    • One value: All attributes are set to the same value.

    • Two values: Top and bottom are set to the first value, left and right to the second value.

    • Three values: Top is set to the first, left and right to the second, and bottom to the third value.

    • Four or more values: Top is set to the first, right to the second, bottom to the third and left to the fourth value.

# File lib/hexapdf/layout/style.rb, line 169
def set(obj)
  case obj
  when Quad
    @top = obj.top
    @bottom = obj.bottom
    @left = obj.left
    @right = obj.right
  when Array
    @top = obj[0]
    @bottom = obj[2] || obj[0]
    @left = obj[3] || obj[1] || obj[0]
    @right = obj[1] || obj[0]
  else
    @top = @bottom = @left = @right = obj
  end
end
simple?() click to toggle source

Returns true if the quad effectively contains only one value.

# File lib/hexapdf/layout/style.rb, line 187
def simple?
  @top == @bottom && @top == @left && @top == @right
end