Class: OoxmlParser::DocxDrawing

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb

Overview

Class for parsing ‘graphic` tags

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(properties = DocxDrawingProperties.new, parent: nil) ⇒ DocxDrawing

Returns a new instance of DocxDrawing.



19
20
21
22
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 19

def initialize(properties = DocxDrawingProperties.new, parent: nil)
  @properties = properties
  super(parent: parent)
end

Instance Attribute Details

#doc_propertiesDocProperties

Returns doc properties.

Returns:



15
16
17
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 15

def doc_properties
  @doc_properties
end

#graphicObject Also known as: picture

Returns the value of attribute graphic.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 13

def graphic
  @graphic
end

#idString (readonly)

Returns id of drawing.

Returns:

  • (String)

    id of drawing



12
13
14
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 12

def id
  @id
end

#propertiesObject

Returns the value of attribute properties.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 13

def properties
  @properties
end

#typeObject

Returns the value of attribute type.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 13

def type
  @type
end

Instance Method Details

#parse(node) ⇒ DocxDrawing

Parse DocxDrawing

Parameters:

  • node (Nokogiri::XML:Node)

    with NumberingProperties

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb', line 27

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'id'
      @id = value.value.to_s
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'anchor'
      @type = :flow
    when 'inline'
      @type = :inline
    end
    node_child.xpath('*').each do |content_node_child|
      case content_node_child.name
      when 'graphic'
        @graphic = DocxGraphic.new(parent: self).parse(content_node_child)
      when 'docPr'
        @doc_properties = DocProperties.new(parent: self).parse(content_node_child)
      end
    end
    @properties.parse(node_child)
  end
  self
end