class RubyDocx::Elements::Element

Attributes

doc[R]
grid[R]
node[R]
style[R]

Public Class Methods

new(doc, node) click to toggle source
# 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

Public Instance Methods

elements() click to toggle source
# 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
Also aliased as: parse_elements
inspect() click to toggle source
# File lib/ruby_docx/elements/element.rb, line 49
def inspect
  "#<#{self.class} @node=#{@node.name}>"
end
parse_elements()
Alias for: elements
to_s() click to toggle source
# File lib/ruby_docx/elements/element.rb, line 23
def to_s
  @node.to_s
end
to_xml() click to toggle source
# File lib/ruby_docx/elements/element.rb, line 27
def to_xml
  @node.to_s
end