Class: RubyDocx::Elements::Element
- Inherits:
-
Object
- Object
- RubyDocx::Elements::Element
- Defined in:
- lib/ruby_docx/elements/element.rb
Direct Known Subclasses
Bookmark, BreakLine, Drawing, Equation, Image, Link, OleObject, Paragraph, Style, Table, TableCell, TableColumn, TableRow, TableStyle, Text, TextRun
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#grid ⇒ Object
readonly
Returns the value of attribute grid.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
- #elements ⇒ Object (also: #parse_elements)
-
#initialize(doc, node) ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(doc, node) ⇒ Element
Returns a new instance of Element.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_docx/elements/element.rb', line 8 def initialize(doc, node) @node = node @doc = doc if self.node.name.to_s == "pict" @doc.setup_image(self) elsif self.node.name.to_s == "drawing" @doc.setup_drawing(self) elsif self.node.name.to_s == "object" @doc.setup_object(self) end self.parse_elements end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
5 6 7 |
# File 'lib/ruby_docx/elements/element.rb', line 5 def doc @doc end |
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
5 6 7 |
# File 'lib/ruby_docx/elements/element.rb', line 5 def grid @grid end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/ruby_docx/elements/element.rb', line 5 def node @node end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
5 6 7 |
# File 'lib/ruby_docx/elements/element.rb', line 5 def style @style end |
Instance Method Details
#elements ⇒ Object Also known as: parse_elements
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby_docx/elements/element.rb', line 31 def elements @elements ||= @node.children.map do |c_node| v = RubyDocx::Elements::Parser.parse_by_name(@doc, c_node) if ["pPr", "rPr", "tblPr", "tcPr"].index(c_node.name.to_s) @style = v nil elsif ["tblGrid"].index(c_node.name.to_s) @grid = v nil else v end end.compact end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/ruby_docx/elements/element.rb', line 49 def inspect "#<#{self.class} @node=#{@node.name}>" end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/ruby_docx/elements/element.rb', line 23 def to_s @node.to_s end |
#to_xml ⇒ Object
27 28 29 |
# File 'lib/ruby_docx/elements/element.rb', line 27 def to_xml @node.to_s end |