Class: Fr::TZipper::RootCursor
Instance Attribute Summary collapse
Query the Tree Location
collapse
Traversing the Tree
collapse
Editing the Tree
collapse
Instance Method Summary
collapse
#append_child, #between, #child, #children, #dangle, #descendant, #down, #flatten, #insert_left, #insert_right, #prepend_child
Constructor Details
Returns a new instance of RootCursor.
12
13
14
15
|
# File 'lib/fr/tzipper/root_cursor.rb', line 12
def initialize(node)
@node, @path =
node, Root
end
|
Instance Attribute Details
#node ⇒ AbstractNode
7
8
9
|
# File 'lib/fr/tzipper/root_cursor.rb', line 7
def node
@node
end
|
10
11
12
|
# File 'lib/fr/tzipper/root_cursor.rb', line 10
def path
@path
end
|
Instance Method Details
#append(node) ⇒ void
This method returns an undefined value.
90
91
92
93
|
# File 'lib/fr/tzipper/root_cursor.rb', line 90
def append(node)
raise Errors::ZipperError,
"root node has no siblings"
end
|
#delete ⇒ void
This method returns an undefined value.
110
111
112
113
|
# File 'lib/fr/tzipper/root_cursor.rb', line 110
def delete
raise Errors::ZipperError,
"cannot delete root node"
end
|
21
22
23
|
# File 'lib/fr/tzipper/root_cursor.rb', line 21
def depth
0
end
|
49
50
51
|
# File 'lib/fr/tzipper/root_cursor.rb', line 49
def first
self
end
|
26
27
28
|
# File 'lib/fr/tzipper/root_cursor.rb', line 26
def first?
true
end
|
118
119
120
|
# File 'lib/fr/tzipper/root_cursor.rb', line 118
def inspect
"Cursor(Root, #{@node.inspect})"
end
|
54
55
56
|
# File 'lib/fr/tzipper/root_cursor.rb', line 54
def last
self
end
|
31
32
33
|
# File 'lib/fr/tzipper/root_cursor.rb', line 31
def last?
true
end
|
#leaf? ⇒ Boolean
36
37
38
|
# File 'lib/fr/tzipper/root_cursor.rb', line 36
def leaf?
@node.leaf? or @node.children.empty?
end
|
#next ⇒ void
This method returns an undefined value.
60
61
62
63
|
# File 'lib/fr/tzipper/root_cursor.rb', line 60
def next
raise Errors::ZipperError,
"root node has no siblings"
end
|
#prepend(node) ⇒ void
This method returns an undefined value.
97
98
99
100
|
# File 'lib/fr/tzipper/root_cursor.rb', line 97
def prepend(node)
raise Errors::ZipperError,
"root node has no siblings"
end
|
#prev ⇒ void
This method returns an undefined value.
67
68
69
70
|
# File 'lib/fr/tzipper/root_cursor.rb', line 67
def prev
raise Errors::ZipperError,
"root node has no siblings"
end
|
104
105
106
|
# File 'lib/fr/tzipper/root_cursor.rb', line 104
def replace(node)
RootCursor.new(node)
end
|
Navigate to the root node
74
75
76
|
# File 'lib/fr/tzipper/root_cursor.rb', line 74
def root
self
end
|
#root? ⇒ Boolean
41
42
43
|
# File 'lib/fr/tzipper/root_cursor.rb', line 41
def root?
true
end
|
#up ⇒ void
This method returns an undefined value.
80
81
82
83
|
# File 'lib/fr/tzipper/root_cursor.rb', line 80
def up
raise Errors::ZipperError,
"root node has no parent"
end
|