Class: OoxmlParser::ParagraphBorders

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb

Overview

Class for parsing ‘w:pBdr` element

Direct Known Subclasses

Borders

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#barBordersProperties

Returns bar properties.

Returns:



17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 17

def bar
  @bar
end

#betweenBordersProperties

Returns between properties.

Returns:



15
16
17
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 15

def between
  @between
end

#bottomBordersProperties

Returns bottom properties.

Returns:



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 7

def bottom
  @bottom
end

#leftBordersProperties

Returns left properties.

Returns:



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 9

def left
  @left
end

#rightBordersProperties

Returns right properties.

Returns:



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 13

def right
  @right
end

#topBordersProperties

Returns top properties.

Returns:



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 11

def top
  @top
end

Instance Method Details

#border_visual_typeSymbol

Returns type of border in visual editor.

Returns:

  • (Symbol)

    type of border in visual editor



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 20

def border_visual_type
  result = []
  result << :left if @left.val == :single
  result << :right if @right.val == :single
  result << :top if @top.val == :single
  result << :bottom if @bottom.val == :single
  result << :inner if @between.val == :single
  return :none if result == []
  return :all if result == %i[left right top bottom inner]
  return :outer if result == %i[left right top bottom]

  result.first if result.size == 1
end

#parse(node) ⇒ ParagraphBorders

Parse Paragraph Borders data

Parameters:

  • node (Nokogiri::XML:Element)

    with Paragraph Borders data

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb', line 37

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'bottom'
      @bottom = BordersProperties.new(parent: self).parse(node_child)
    when 'left'
      @left = BordersProperties.new(parent: self).parse(node_child)
    when 'top'
      @top = BordersProperties.new(parent: self).parse(node_child)
    when 'right'
      @right = BordersProperties.new(parent: self).parse(node_child)
    when 'between'
      @between = BordersProperties.new(parent: self).parse(node_child)
    when 'bar'
      @bar = BordersProperties.new(parent: self).parse(node_child)
    end
  end
  self
end