Class: Rapid::Template::Node::Root
- Defined in:
- lib/rapid/template/node/root.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Attributes inherited from Base
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #content ⇒ Object
-
#initialize(nodes) ⇒ Root
constructor
A new instance of Root.
- #inspect ⇒ Object
- #next_to(node) ⇒ Object
- #pull(result) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(nodes) ⇒ Root
Returns a new instance of Root.
9 10 11 12 13 14 15 |
# File 'lib/rapid/template/node/root.rb', line 9 def initialize nodes @nodes = nodes nodes.each do |n| n.send :parent=, self end end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
7 8 9 |
# File 'lib/rapid/template/node/root.rb', line 7 def nodes @nodes end |
Instance Method Details
#==(obj) ⇒ Object
39 40 41 |
# File 'lib/rapid/template/node/root.rb', line 39 def == obj obj.is_a?(self.class) && obj.nodes == @nodes end |
#content ⇒ Object
35 36 37 |
# File 'lib/rapid/template/node/root.rb', line 35 def content nodes.first.content if nodes.first end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/rapid/template/node/root.rb', line 43 def inspect %(#<root nodes=#{@nodes.inspect}>) end |
#next_to(node) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rapid/template/node/root.rb', line 17 def next_to node # OPTIMIZE need object level eql? this the best way? index = nil nodes.each_with_index {|n, i| index = i if node.eql? n } return unless index node = nodes[index+1] return node if node parent.next_node if parent end |
#pull(result) ⇒ Object
29 30 31 32 33 |
# File 'lib/rapid/template/node/root.rb', line 29 def pull result @nodes.each do |node| node.pull result end end |