Class: OoxmlParser::DocxDrawing
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocxDrawing
- 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
-
#doc_properties ⇒ DocProperties
Doc properties.
-
#graphic ⇒ Object
(also: #picture)
Returns the value of attribute graphic.
-
#id ⇒ String
readonly
Id of drawing.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(properties = DocxDrawingProperties.new, parent: nil) ⇒ DocxDrawing
constructor
A new instance of DocxDrawing.
-
#parse(node) ⇒ DocxDrawing
Parse DocxDrawing.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
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_properties ⇒ DocProperties
Returns doc properties.
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 |
#graphic ⇒ Object 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 |
#id ⇒ String (readonly)
Returns 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 |
#properties ⇒ Object
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 |
#type ⇒ Object
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
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 |