Class: OoxmlParser::DocxWrapDrawing

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

Overview

Docx Wrap Drawing

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ DocxWrapDrawing

Returns a new instance of DocxWrapDrawing.



6
7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 6

def initialize(parent: nil)
  @wrap_text = :none
  @parent = parent
end

Instance Attribute Details

#distance_from_textObject

Returns the value of attribute distance_from_text.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 4

def distance_from_text
  @distance_from_text
end

#wrap_textObject

Returns the value of attribute wrap_text.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 4

def wrap_text
  @wrap_text
end

Instance Method Details

#parse(node) ⇒ DocxWrapDrawing

Parse DocxWrapDrawing object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 14

def parse(node)
  unless node.attribute('behindDoc').nil?
    @wrap_text = :behind if node.attribute('behindDoc').value == '1'
    @wrap_text = :infront if node.attribute('behindDoc').value == '0'
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'wrapSquare'
      @wrap_text = :square
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    when 'wrapTight'
      @wrap_text = :tight
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    when 'wrapThrough'
      @wrap_text = :through
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    when 'wrapTopAndBottom'
      @wrap_text = :topbottom
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    end
  end
  self
end