Class: OoxmlParser::DocxShapeLineElement

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb

Overview

Docx Shape Line Element

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

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(points = [], parent: nil) ⇒ DocxShapeLineElement

Returns a new instance of DocxShapeLineElement.



8
9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb', line 8

def initialize(points = [], parent: nil)
  @points = points
  super(parent: parent)
end

Instance Attribute Details

#pointsObject

Returns the value of attribute points.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb', line 6

def points
  @points
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb', line 6

def type
  @type
end

Instance Method Details

#parse(node) ⇒ DocxShapeLineElement

Parse DocxShapeLineElement

Parameters:

  • node (Nokogiri::XML:Node)

    with DocxShapeLineElement

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb', line 16

def parse(node)
  case node.name
  when 'moveTo'
    @type = :move
  when 'lnTo'
    @type = :line
  when 'arcTo'
    @type = :arc
  when 'cubicBezTo'
    @type = :cubic_bezier
  when 'close'
    @type = :close
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'pt'
      @points << OOXMLCoordinates.new(parent: self).parse(node_child)
    end
  end
  self
end