Class: Fr::TZipper::DanglingCursor
Instance Attribute Summary collapse
Querying 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, #root
Constructor Details
Returns a new instance of DanglingCursor.
9
10
11
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 9
def initialize(parent)
@parent = parent
end
|
Instance Attribute Details
7
8
9
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 7
def parent
@parent
end
|
Instance Method Details
94
95
96
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 94
def delete
self
end
|
38
39
40
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 38
def depth
@parent.depth + 1
end
|
73
74
75
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 73
def first
self
end
|
#first? ⇒ Boolean
43
44
45
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 43
def first?
true
end
|
101
102
103
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 101
def inspect
"Cursor(..., ___)"
end
|
78
79
80
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 78
def last
self
end
|
#last? ⇒ Boolean
48
49
50
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 48
def last?
true
end
|
#leaf? ⇒ Boolean
28
29
30
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 28
def leaf?
true
end
|
61
62
63
64
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 61
def next
raise Errors::ZipperError,
"cannot move to next after last node"
end
|
14
15
16
17
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 14
def node
raise Errors::ZipperError,
"DanglingCursor#node should not be called"
end
|
20
21
22
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 20
def path
Hole.new([], @parent.path.parent, [])
end
|
67
68
69
70
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 67
def prev
raise Errors::ZipperError,
"cannot move to prev before first node"
end
|
#replace(node) ⇒ Object
Also known as:
prepend, append
86
87
88
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 86
def replace(node)
@parent.append_child(node)
end
|
#root? ⇒ Boolean
33
34
35
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 33
def root?
false
end
|
56
57
58
|
# File 'lib/fr/tzipper/dangling_cursor.rb', line 56
def up
@parent
end
|