Class: Rind::Children

Inherits:
Nodes
  • Object
show all
Includes:
Enumerable, Equality
Defined in:
lib/rind/nodes.rb

Overview

All of the Array functions have been modified to work with Children. Functions like pop that remove a node and return it will remove the association to the parent node. Functions like “push” will automatically associate the nodes to the parent.

Instance Method Summary collapse

Methods included from Equality

#==, #eql?

Methods inherited from Nodes

#exact_index, #filter

Constructor Details

#initialize(parent, *nodes) ⇒ Children

Returns a new instance of Children.



190
191
192
193
194
# File 'lib/rind/nodes.rb', line 190

def initialize(parent, *nodes)
	super(nodes)
	@parent = parent
	fix_children!
end

Instance Method Details

#delete(child, &block) ⇒ Object

:nodoc:



230
231
232
233
234
235
# File 'lib/rind/nodes.rb', line 230

def delete(child, &block) # :nodoc:
	child = Rind::Text.new(child) if child.is_a?(String)
	node = super(child, &block)
	node.parent = nil if node.respond_to? :parent
	node
end

#render!Object

Replace the child nodes with their rendered values.



238
239
240
241
# File 'lib/rind/nodes.rb', line 238

def render!
	nodes = collect{|child| child.respond_to?(:render!) ? child.render! : child}.flatten
	replace(nodes)
end