Class: Uniword::PageBorders

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/page_borders.rb

Overview

Represents page borders for a section

Page borders can be applied to all sides of pages in a section.

Examples:

Create page borders

borders = PageBorders.new(
  display: 'allPages',
  offset_from: 'page'
)
borders.top = PageBorderSide.new(style: 'double', color: '000000', width: 12)

Constant Summary collapse

DISPLAY_OPTIONS =

Display options

%w[allPages firstPage notFirstPage].freeze
OFFSET_OPTIONS =

Offset reference options

%w[page text].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ PageBorders

Returns a new instance of PageBorders.



70
71
72
73
74
# File 'lib/uniword/page_borders.rb', line 70

def initialize(**attributes)
  super
  validate_display
  validate_offset_from
end

Instance Attribute Details

#bottomPageBorderSide

Bottom border

Returns:



56
57
58
# File 'lib/uniword/page_borders.rb', line 56

def bottom
  @bottom
end

#displayString

When to display borders (allPages, firstPage, notFirstPage)

Returns:

  • (String)

    the current value of display



56
57
58
# File 'lib/uniword/page_borders.rb', line 56

def display
  @display
end

#leftPageBorderSide

Left border

Returns:



56
57
58
# File 'lib/uniword/page_borders.rb', line 56

def left
  @left
end

#offset_fromString

Measurement reference (page, text)

Returns:

  • (String)

    the current value of offset_from



56
57
58
# File 'lib/uniword/page_borders.rb', line 56

def offset_from
  @offset_from
end

#rightPageBorderSide

Right border

Returns:



56
57
58
# File 'lib/uniword/page_borders.rb', line 56

def right
  @right
end

#topPageBorderSide

Top border

Returns:



56
57
58
# File 'lib/uniword/page_borders.rb', line 56

def top
  @top
end

Class Method Details

.all_sides(style: "single", color: "auto", width: 6) ⇒ PageBorders

Create borders on all sides with same properties

Parameters:

  • style (String) (defaults to: "single")

    Border style

  • color (String) (defaults to: "auto")

    Border color

  • width (Integer) (defaults to: 6)

    Border width

  • options (Hash)

    Additional options (display, offset_from)

Returns:



83
84
85
86
87
88
89
90
91
92
# File 'lib/uniword/page_borders.rb', line 83

def self.all_sides(style: "single", color: "auto", width: 6, **)
  border_side = PageBorderSide.new(style: style, color: color, width: width)
  new(
    top: border_side,
    bottom: border_side,
    left: border_side,
    right: border_side,
    **
  )
end

Instance Method Details

#any?Boolean

Check if any border is defined

Returns:

  • (Boolean)

    true if any border exists



97
98
99
# File 'lib/uniword/page_borders.rb', line 97

def any?
  !top.nil? || !bottom.nil? || !left.nil? || !right.nil?
end