Class: OoxmlParser::DocxShapeLine

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb

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) ⇒ DocxShapeLine

Returns a new instance of DocxShapeLine.



12
13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 12

def initialize(parent: nil)
  @width = OoxmlSize.new(0)
  @parent = parent
end

Instance Attribute Details

#capObject

Returns the value of attribute cap.



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

def cap
  @cap
end

#color_schemeObject Also known as: color

Returns the value of attribute color_scheme.



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

def color_scheme
  @color_scheme
end

#dashValuedChild

Returns dash properties.

Returns:



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 8

def dash
  @dash
end

#fillObject

Returns the value of attribute fill.



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

def fill
  @fill
end

#head_endObject

Returns the value of attribute head_end.



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

def head_end
  @head_end
end

#tail_endObject

Returns the value of attribute tail_end.



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

def tail_end
  @tail_end
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#nil?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 25

def nil?
  stroke_size.zero? && cap.nil?
end

#parse(node) ⇒ DocxShapeLine

Parse DocxShapeLine object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 32

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'w'
      @width = OoxmlSize.new(value.value.to_f, :emu)
    when 'cap'
      @cap = value_to_symbol(value)
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'solidFill'
      @color_scheme = DocxColorScheme.new(parent: self).parse(node_child)
    when 'noFill'
      @width = OoxmlSize.new(0)
    when 'headEnd'
      @head_end = LineEnd.new(parent: self).parse(node_child)
    when 'tailEnd'
      @tail_end = LineEnd.new(parent: self).parse(node_child)
    when 'prstDash'
      @dash = ValuedChild.new(:symbol, parent: self).parse(node_child)
    end
  end
  self
end

#stroke_sizeObject



17
18
19
20
21
22
23
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 17

def stroke_size
  if @color_scheme.nil? || @color_scheme.color == :none
    0
  else
    @width
  end
end