Class: OoxmlParser::Shape
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Shape
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb
Overview
Class for parsing ‘shape`, `rect`, `oval` tags
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#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(type = nil, properties = ShapeProperties.new, elements = [], parent: nil) ⇒ Shape
constructor
A new instance of Shape.
-
#parse(node, type) ⇒ Shape
Parse Shape object.
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(type = nil, properties = ShapeProperties.new, elements = [], parent: nil) ⇒ Shape
Returns a new instance of Shape.
9 10 11 12 13 14 15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb', line 9 def initialize(type = nil, properties = ShapeProperties.new, elements = [], parent: nil) @type = type @properties = properties @elements = elements super(parent: parent) end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
7 8 9 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb', line 7 def elements @elements end |
#properties ⇒ Object
Returns the value of attribute properties.
7 8 9 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb', line 7 def properties @properties end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb', line 7 def type @type end |
Instance Method Details
#parse(node, type) ⇒ Shape
Parse Shape object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb', line 22 def parse(node, type) @type = type node.attributes.each do |key, value| case key when 'fillcolor' @properties.fill_color = Color.new(parent: self) .parse_hex_string(value_to_hex(value)) when 'strokecolor' @properties.stroke.color = Color.new(parent: self) .parse_hex_string(value_to_hex(value)) when 'strokeweight' @properties.stroke.weight = value.value when 'style' parse_style(value.value) end end node.xpath('*').each do |node_child| case node_child.name when 'textbox' @elements = TextBox.new(parent: parent).parse_list(node_child) end end self end |