Class: Uniword::ParagraphBorders

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

Overview

Represents paragraph borders

Paragraph borders can be applied to individual sides or between paragraphs.

Examples:

Create paragraph with borders

borders = ParagraphBorders.new
borders.top = ParagraphBorderSide.new(style: 'single', color: '000000', size: 6)
borders.bottom = ParagraphBorderSide.new(style: 'double', color: 'FF0000', size: 12)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#betweenParagraphBorderSide

Border between paragraphs

Returns:



60
61
62
# File 'lib/uniword/paragraph_border.rb', line 60

def between
  @between
end

#bottomParagraphBorderSide

Bottom border

Returns:



60
61
62
# File 'lib/uniword/paragraph_border.rb', line 60

def bottom
  @bottom
end

#leftParagraphBorderSide

Left border

Returns:



60
61
62
# File 'lib/uniword/paragraph_border.rb', line 60

def left
  @left
end

#rightParagraphBorderSide

Right border

Returns:



60
61
62
# File 'lib/uniword/paragraph_border.rb', line 60

def right
  @right
end

#topParagraphBorderSide

Top border

Returns:



60
61
62
# File 'lib/uniword/paragraph_border.rb', line 60

def top
  @top
end

Class Method Details

.all_sides(style: "single", color: "auto", size: 6, space: 1) ⇒ ParagraphBorders

Create borders on all sides with same properties

Parameters:

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

    Border style

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

    Border color

  • size (Integer) (defaults to: 6)

    Border size

  • space (Integer) (defaults to: 1)

    Space from text

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/uniword/paragraph_border.rb', line 74

def self.all_sides(style: "single", color: "auto", size: 6, space: 1)
  border_side = ParagraphBorderSide.new(
    style: style,
    color: color,
    size: size,
    space: space,
  )
  new(
    top: border_side,
    bottom: border_side,
    left: border_side,
    right: border_side,
  )
end

.box(style: "single", color: "auto", size: 6, space: 1) ⇒ ParagraphBorders

Create box borders (all sides, no between)

Parameters:

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

    Border style

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

    Border color

  • size (Integer) (defaults to: 6)

    Border size

  • space (Integer) (defaults to: 1)

    Space from text

Returns:



96
97
98
# File 'lib/uniword/paragraph_border.rb', line 96

def self.box(style: "single", color: "auto", size: 6, space: 1)
  all_sides(style: style, color: color, size: size, space: space)
end

Instance Method Details

#any?Boolean

Check if any border is defined

Returns:

  • (Boolean)

    true if any border exists



103
104
105
# File 'lib/uniword/paragraph_border.rb', line 103

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

#box?Boolean

Check if this creates a complete box

Returns:

  • (Boolean)

    true if all four sides are defined



110
111
112
# File 'lib/uniword/paragraph_border.rb', line 110

def box?
  !top.nil? && !bottom.nil? && !left.nil? && !right.nil?
end