Sha256: a41e52ec4ef35f1397814b72891569025ba1911d73dd1e9bd865e566797894b7

Contents?: true

Size: 1.96 KB

Versions: 45

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `w:pBdr` element
  class ParagraphBorders < OOXMLDocumentObject
    # @return [BordersProperties] bottom properties
    attr_accessor :bottom
    # @return [BordersProperties] left properties
    attr_accessor :left
    # @return [BordersProperties] top properties
    attr_accessor :top
    # @return [BordersProperties] right properties
    attr_accessor :right
    # @return [BordersProperties] between properties
    attr_accessor :between
    # @return [BordersProperties] bar properties
    attr_accessor :bar

    # @return [Symbol] type of border in visual editor
    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 Paragraph Borders data
    # @param [Nokogiri::XML:Element] node with Paragraph Borders data
    # @return [ParagraphBorders] value of Paragraph Borders data
    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
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb