Sha256: d13af7c748aacf6f15f4544e4329f8e3d8dbb7c58db13840053dedd3d9c85d08

Contents?: true

Size: 1.63 KB

Versions: 40

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require_relative 'color/docx_color_scheme'
require_relative 'line/line_end'
module OoxmlParser
  # Docx Shape Line
  class DocxShapeLine < OOXMLDocumentObject
    attr_accessor :width, :color_scheme, :cap, :head_end, :tail_end, :fill
    # @return [ValuedChild] dash properties
    attr_accessor :dash

    alias color color_scheme

    def initialize(parent: nil)
      @width = OoxmlSize.new(0)
      super
    end

    # @return [Integer] stroke size of object
    def stroke_size
      if @color_scheme.nil? || @color_scheme.color == :none
        0
      else
        @width
      end
    end

    # @return [True, False] is line invisible
    def invisible?
      stroke_size.zero? && cap.nil?
    end

    # Parse DocxShapeLine object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [DocxShapeLine] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'w'
          @width = OoxmlSize.new(value.value.to_f, :emu)
        when 'cap'
          @cap = value_to_symbol(value)
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'solidFill'
          @color_scheme = DocxColorScheme.new(parent: self).parse(node_child)
        when 'noFill'
          @width = OoxmlSize.new(0)
        when 'headEnd'
          @head_end = LineEnd.new(parent: self).parse(node_child)
        when 'tailEnd'
          @tail_end = LineEnd.new(parent: self).parse(node_child)
        when 'prstDash'
          @dash = ValuedChild.new(:symbol, parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb