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

Overview

Docx Shape Line

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(parent: nil) ⇒ DocxShapeLine

Returns a new instance of DocxShapeLine.



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

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

Instance Attribute Details

#capObject

Returns the value of attribute cap.



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 cap
  @cap
end

#color_schemeObject Also known as: color

Returns the value of attribute color_scheme.



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 color_scheme
  @color_scheme
end

#dashValuedChild

Returns dash properties.

Returns:



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

def dash
  @dash
end

#fillObject

Returns the value of attribute fill.



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 fill
  @fill
end

#head_endObject

Returns the value of attribute head_end.



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 head_end
  @head_end
end

#tail_endObject

Returns the value of attribute tail_end.



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 tail_end
  @tail_end
end

#widthObject

Returns the value of attribute width.



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 width
  @width
end

Instance Method Details

#invisible?True, False

Returns is line invisible.

Returns:

  • (True, False)

    is line invisible



29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 29

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

#parse(node) ⇒ DocxShapeLine

Parse DocxShapeLine object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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

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_sizeInteger

Returns stroke size of object.

Returns:

  • (Integer)

    stroke size of object



20
21
22
23
24
25
26
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 20

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