Class: OoxmlParser::DocxShapeLinePath

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.rb

Constant Summary

Constants inherited from OOXMLDocumentObject

OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file

Constructor Details

#initialize(elements = []) ⇒ DocxShapeLinePath

Returns a new instance of DocxShapeLinePath.



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.rb', line 6

def initialize(elements = [])
  @elements = elements
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



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

def elements
  @elements
end

#fillObject

Returns the value of attribute fill.



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

def fill
  @fill
end

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#strokeObject

Returns the value of attribute stroke.



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

def stroke
  @stroke
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Class Method Details

.parse(path_node) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb', line 10

def self.parse(path_node)
  shape_line_path = DocxShapeLinePath.new
  path_node.attributes.each do |key, value|
    case key
    when 'w'
      shape_line_path.width = value.value.to_f
    when 'h'
      shape_line_path.height = value.value.to_f
    when 'stroke'
      shape_line_path.stroke = value.value.to_f
    end
  end
  path_node.xpath('*').each do |line_path_element_node|
    line_element = DocxShapeLineElement.new
    case line_path_element_node.name
    when 'moveTo'
      line_element.type = :move
    when 'lnTo'
      line_element.type = :line
    when 'arcTo'
      line_element.type = :arc
    when 'cubicBezTo'
      line_element.type = :cubic_bezier
    when 'quadBezTo'
      line_element.type = :quadratic_bezier
    when 'close'
      line_element.type = :close
    end
    line_path_element_node.xpath('a:pt', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').each { |point_node| line_element.points << OOXMLCoordinates.parse(point_node, delimiter: 1) }
    shape_line_path.elements << line_element
  end
  shape_line_path
end