Class: OoxmlParser::DocxShapeLine

Inherits:
Object
  • Object
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDocxShapeLine

Returns a new instance of DocxShapeLine.



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 initialize
  @width = 0
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

#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

Class Method Details

.parse(shape_line_node) ⇒ Object



26
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
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb', line 26

def self.parse(shape_line_node)
  shape_line = DocxShapeLine.new
  shape_line.width = (shape_line_node.attribute('w').value.to_f / 12_699.3).round(2) unless shape_line_node.attribute('w').nil?
  unless shape_line_node.attribute('cap').nil?
    case shape_line_node.attribute('cap').value
    when 'rnd'
      shape_line.cap = :round
    when 'sq'
      shape_line.cap = :square
    when 'flat'
      shape_line.cap = :flat
    end
  end
  shape_line_node.xpath('*').each do |shape_line_node_child|
    case shape_line_node_child.name
    when 'solidFill'
      shape_line.color_scheme = DocxColorScheme.parse(shape_line_node_child)
    when 'noFill'
      shape_line.width = 0
    when 'headEnd'
      shape_line.head_end = LineEnd.parse(shape_line_node_child)
    when 'tailEnd'
      shape_line.tail_end = LineEnd.parse(shape_line_node_child)
    end
  end
  shape_line
end

Instance Method Details

#nil?Boolean

Returns:

  • (Boolean)


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

def nil?
  stroke_size == 0 && cap.nil?
end

#stroke_sizeObject



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

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