Module: Docx::Elements::Element::ClassMethods

Defined in:
lib/docx/elements/element.rb

Instance Method Summary collapse

Instance Method Details

#create_with(element) ⇒ Object



58
59
60
61
# File 'lib/docx/elements/element.rb', line 58

def create_with(element)
  # Need to somehow get the xml document accessible here by default, but this is alright in the interim
  self.new(Nokogiri::XML::Node.new("w:#{self.const_get(:TAG)}", element.node))
end

#create_within(element) ⇒ Object



63
64
65
66
67
# File 'lib/docx/elements/element.rb', line 63

def create_within(element)
  new_element = create_with(element)
  new_element.append_to(element)
  new_element
end