Module: Arboretum::DocTree::Elements::Contextualized
- Included in:
- AdjacentElementGroup, Element
- Defined in:
- lib/arboretum/doctree.rb
Instance Method Summary collapse
-
#swap(other) ⇒ Object
Swap locations of this ContextualGroup with another ContextualGroup.
-
#wrap(element, index = -1)) {|element| ... } ⇒ Object
Wrap this ContextualGroup in an Element, with the wrapping Element taking this ContextualGroup’s original place in the tree If the wrapping Element already exitst, then this ContextualGroup is pushed to the given index in the other’s children (but also idk why would you need to do that?).
Instance Method Details
#swap(other) ⇒ Object
Swap locations of this ContextualGroup with another ContextualGroup
394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/arboretum/doctree.rb', line 394 def swap(other) puts "Warning: Can't swap with nil" if other.nil? unless other.nil? # Temp other_parent = other.parent other_index = other.index_in_parent other.graft_onto(self.parent, self.index_in_parent) self.graft_onto(other_parent, other_index) end end |
#wrap(element, index = -1)) {|element| ... } ⇒ Object
Wrap this ContextualGroup in an Element, with the wrapping Element taking this ContextualGroup’s original place in the tree If the wrapping Element already exitst, then this ContextualGroup is pushed to the given index in the other’s children (but also idk why would you need to do that?)
408 409 410 411 412 413 414 |
# File 'lib/arboretum/doctree.rb', line 408 def wrap(element, index=-1) element = Element.create(element) if element.is_a?(Hash) element.graft_onto(self.parent, self.index_in_parent) self.graft_onto(element, index) yield element if block_given? element end |