Class: OoxmlParser::DocxParagraphRun
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocxParagraphRun
- Includes:
- DocxParagraphRunHelpers
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb
Overview
Class for working with DocxParagraphRun
Instance Attribute Summary collapse
-
#alternate_content ⇒ Object
Returns the value of attribute alternate_content.
-
#break ⇒ Object
Returns the value of attribute break.
-
#caps ⇒ Object
Returns the value of attribute caps.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#drawings ⇒ Object
Returns the value of attribute drawings.
-
#effect ⇒ Object
Returns the value of attribute effect.
-
#em ⇒ Object
Returns the value of attribute em.
-
#endnote ⇒ Object
Returns the value of attribute endnote.
-
#fld_char ⇒ Object
Returns the value of attribute fld_char.
-
#font ⇒ Object
Returns the value of attribute font.
-
#font_color ⇒ Object
Returns the value of attribute font_color.
-
#font_style ⇒ Object
Returns the value of attribute font_style.
-
#footnote ⇒ Object
Returns the value of attribute footnote.
-
#highlight ⇒ Object
Returns the value of attribute highlight.
-
#instruction_text ⇒ InstructionText
readonly
Text of instruction See ECMA-376, 17.16.23 instrText (Field Code).
-
#link ⇒ Object
Returns the value of attribute link.
-
#number ⇒ Object
Returns the value of attribute number.
-
#object ⇒ RunObject
Object of run.
-
#page_number ⇒ Object
Returns the value of attribute page_number.
-
#position ⇒ Object
Returns the value of attribute position.
-
#run_properties ⇒ RunProperties
Properties of run.
-
#shade ⇒ Shade
Shade properties.
-
#shape ⇒ Object
Returns the value of attribute shape.
-
#size ⇒ Object
Returns the value of attribute size.
-
#spacing ⇒ Object
Returns the value of attribute spacing.
-
#style ⇒ Object
Returns the value of attribute style.
-
#text ⇒ Object
Returns the value of attribute text.
-
#text_fill ⇒ Object
Returns the value of attribute text_fill.
-
#text_outline ⇒ Object
Returns the value of attribute text_outline.
-
#touch ⇒ Object
Returns the value of attribute touch.
-
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
-
#w ⇒ Object
Returns the value of attribute w.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#==(other) ⇒ True, False
Compare this object to other.
-
#drawing ⇒ Array?
Drawings of Run.
-
#empty? ⇒ True, False
Is current run empty.
-
#initialize(parent: nil) ⇒ DocxParagraphRun
constructor
A new instance of DocxParagraphRun.
-
#initialize_copy(source) ⇒ void
Constructor for copy of object.
-
#parse(r_tag, char_number, parent: nil) ⇒ void
Parse object.
Methods included from DocxParagraphRunHelpers
#background_color, #parse_properties
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(parent: nil) ⇒ DocxParagraphRun
Returns a new instance of DocxParagraphRun.
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.rb', line 29 def initialize(parent: nil) @number = 0 @font = 'Arial' @vertical_align = :baseline @size = 11 @font_color = Color.new @font_style = FontStyle.new @text = '' @drawings = [] @w = false @position = 0.0 @spacing = 0.0 @break = false @comments = [] @page_number = false super end |
Instance Attribute Details
#alternate_content ⇒ Object
Returns the value of attribute alternate_content.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def alternate_content @alternate_content end |
#break ⇒ Object
Returns the value of attribute break.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def break @break end |
#caps ⇒ Object
Returns the value of attribute caps.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def caps @caps end |
#comments ⇒ Object
Returns the value of attribute comments.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def comments @comments end |
#drawings ⇒ Object
Returns the value of attribute drawings.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def drawings @drawings end |
#effect ⇒ Object
Returns the value of attribute effect.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def effect @effect end |
#em ⇒ Object
Returns the value of attribute em.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def em @em end |
#endnote ⇒ Object
Returns the value of attribute endnote.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def endnote @endnote end |
#fld_char ⇒ Object
Returns the value of attribute fld_char.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def fld_char @fld_char end |
#font ⇒ Object
Returns the value of attribute font.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def font @font end |
#font_color ⇒ Object
Returns the value of attribute font_color.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def font_color @font_color end |
#font_style ⇒ Object
Returns the value of attribute font_style.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def font_style @font_style end |
#footnote ⇒ Object
Returns the value of attribute footnote.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def footnote @footnote end |
#highlight ⇒ Object
Returns the value of attribute highlight.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def highlight @highlight end |
#instruction_text ⇒ InstructionText (readonly)
Returns text of instruction See ECMA-376, 17.16.23 instrText (Field Code).
21 22 23 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 21 def instruction_text @instruction_text end |
#link ⇒ Object
Returns the value of attribute link.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def link @link end |
#number ⇒ Object
Returns the value of attribute number.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def number @number end |
#object ⇒ RunObject
Returns object of run.
25 26 27 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 25 def object @object end |
#page_number ⇒ Object
Returns the value of attribute page_number.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def page_number @page_number end |
#position ⇒ Object
Returns the value of attribute position.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def position @position end |
#run_properties ⇒ RunProperties
Returns properties of run.
23 24 25 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 23 def run_properties @run_properties end |
#shade ⇒ Shade
Returns shade properties.
27 28 29 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 27 def shade @shade end |
#shape ⇒ Object
Returns the value of attribute shape.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def shape @shape end |
#size ⇒ Object
Returns the value of attribute size.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def size @size end |
#spacing ⇒ Object
Returns the value of attribute spacing.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def spacing @spacing end |
#style ⇒ Object
Returns the value of attribute style.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def style @style end |
#text ⇒ Object
Returns the value of attribute text.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def text @text end |
#text_fill ⇒ Object
Returns the value of attribute text_fill.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def text_fill @text_fill end |
#text_outline ⇒ Object
Returns the value of attribute text_outline.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def text_outline @text_outline end |
#touch ⇒ Object
Returns the value of attribute touch.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def touch @touch end |
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def vertical_align @vertical_align end |
#w ⇒ Object
Returns the value of attribute w.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 15 def w @w end |
Instance Method Details
#==(other) ⇒ True, False
Compare this object to other
77 78 79 80 81 82 83 84 85 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 77 def ==(other) ignored_attributes = %i[@number @parent] all_instance_variables = instance_variables significan_attribues = all_instance_variables - ignored_attributes significan_attribues.each do |current_attributes| return false unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes) end true end |
#drawing ⇒ Array?
Returns Drawings of Run.
57 58 59 60 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 57 def drawing # TODO: Rewrite all tests without this methos @drawings.empty? ? nil : drawings.first end |
#empty? ⇒ True, False
Returns is current run empty.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 63 def empty? text.empty? && !alternate_content && !drawing && !object && !shape && !footnote && !endnote && !@break end |
#initialize_copy(source) ⇒ void
This method returns an undefined value.
Constructor for copy of object
50 51 52 53 54 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 50 def initialize_copy(source) super @drawings = source.drawings.clone @comments = source.comments.clone end |
#parse(r_tag, char_number, parent: nil) ⇒ void
This method returns an undefined value.
Parse object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb', line 92 def parse(r_tag, char_number, parent: nil) @parent = parent r_tag.xpath('*').each do |node_child| case node_child.name when 'rPr' parse_properties(node_child) @run_properties = RunProperties.new(parent: self).parse(node_child) when 'instrText' @instruction_text = InstructionText.new(parent: self).parse(node_child) if @instruction_text.hyperlink? @link = @instruction_text.to_hyperlink elsif @instruction_text.page_number? @text = '*PAGE NUMBER*' end when 'fldChar' @field_char_object = FieldChar.new(parent: self).parse(node_child) @fld_char = @field_char_object.type when 't' @text += node_child.text when 'noBreakHyphen' @text += '–' when 'tab' @text += "\t" when 'drawing' @drawings << DocxDrawing.new(parent: self).parse(node_child) when 'AlternateContent' @alternate_content = AlternateContent.new(parent: self).parse(node_child) when 'br' if node_child.attribute('type').nil? @break = :line @text += "\r" else case node_child.attribute('type').value when 'page', 'column' @break = node_child.attribute('type').value.to_sym end end when 'footnoteReference' @footnote = HeaderFooter.new(parent: self).parse(node_child) when 'endnoteReference' @endnote = HeaderFooter.new(parent: self).parse(node_child) when 'pict' node_child.xpath('*').each do |pict_node_child| case pict_node_child.name when 'shape' @shape = Shape.new(parent: self).parse(pict_node_child, :shape) when 'rect' @shape = Shape.new(parent: self).parse(pict_node_child, :rectangle) end end when 'object' @object = RunObject.new(parent: self).parse(node_child) end end @number = char_number end |