Class: OoxmlParser::Borders

Inherits:
ParagraphBorders show all
Defined in:
lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb

Overview

Borders data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from ParagraphBorders

#border_visual_type

Methods inherited from OOXMLDocumentObject

#boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ Borders

Returns a new instance of Borders.



10
11
12
13
14
15
16
17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 10

def initialize(parent: nil)
  @left = BordersProperties.new
  @right = BordersProperties.new
  @top = BordersProperties.new
  @bottom = BordersProperties.new
  @between = BordersProperties.new
  @inner_horizontal = BordersProperties.new
  @inner_vertical = BordersProperties.new
  super
end

Instance Attribute Details

#barObject

Returns the value of attribute bar.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def bar
  @bar
end

#betweenObject

Returns the value of attribute between.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def between
  @between
end

#bottomObject

Returns the value of attribute bottom.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def bottom
  @bottom
end

#displayObject

Returns the value of attribute display.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def display
  @display
end

#inner_horizontalObject

Returns the value of attribute inner_horizontal.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def inner_horizontal
  @inner_horizontal
end

#inner_verticalObject

Returns the value of attribute inner_vertical.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def inner_vertical
  @inner_vertical
end

#leftObject

Returns the value of attribute left.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def left
  @left
end

#offset_fromObject

Returns the value of attribute offset_from.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def offset_from
  @offset_from
end

#rightObject

Returns the value of attribute right.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def right
  @right
end

#topObject

Returns the value of attribute top.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def top
  @top
end

#top_left_to_bottom_rightObject

Returns the value of attribute top_left_to_bottom_right.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def top_left_to_bottom_right
  @top_left_to_bottom_right
end

#top_right_to_bottom_leftObject

Returns the value of attribute top_right_to_bottom_left.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7

def top_right_to_bottom_left
  @top_right_to_bottom_left
end

Instance Method Details

#==(other) ⇒ True, False

Compare this object to other

Parameters:

  • other (Object)

    any other object

Returns:

  • (True, False)

    result of comparision



40
41
42
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 40

def ==(other)
  @left == other.left && @right == other.right && @top == other.top && @bottom == other.bottom if other.is_a?(Borders)
end

#copyBorders

Method to copy object

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 23

def copy
  new_borders = Borders.new
  new_borders.left = @left if @left
  new_borders.right = @right if @right
  new_borders.top = @top if @top
  new_borders.bottom = @bottom if @bottom
  new_borders.inner_vertical = @inner_vertical if @inner_vertical
  new_borders.inner_horizontal = @inner_horizontal if @inner_horizontal
  new_borders.between = @between if @between
  new_borders.display = @display if @display
  new_borders.bar = @bar if @bar
  new_borders
end

#each_border {|bottom| ... } ⇒ Object

Yields:



44
45
46
47
48
49
50
51
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 44

def each_border
  yield(bottom)
  yield(inner_horizontal)
  yield(inner_vertical)
  yield(left)
  yield(right)
  yield(top)
end

#each_side {|bottom| ... } ⇒ Object

Yields:



53
54
55
56
57
58
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 53

def each_side
  yield(bottom)
  yield(left)
  yield(right)
  yield(top)
end

#parse(node) ⇒ Borders

Parse Borders object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 76

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'lnL', 'left'
      @left = TableCellLine.new(parent: self).parse(node_child)
    when 'lnR', 'right'
      @right = TableCellLine.new(parent: self).parse(node_child)
    when 'lnT', 'top'
      @top = TableCellLine.new(parent: self).parse(node_child)
    when 'lnB', 'bottom'
      @bottom = TableCellLine.new(parent: self).parse(node_child)
    when 'insideV'
      @inner_vertical = TableCellLine.new(parent: self).parse(node_child)
    when 'insideH'
      @inner_horizontal = TableCellLine.new(parent: self).parse(node_child)
    end
  end
  self
end

#to_sString

Returns result of convert of object to string.

Returns:

  • (String)

    result of convert of object to string



61
62
63
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 61

def to_s
  "Left border: #{left}, Right: #{right}, Top: #{top}, Bottom: #{bottom}"
end

#visible?Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
71
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 65

def visible?
  visible = false
  each_side do |current_size|
    visible ||= current_size.visible?
  end
  visible
end