Class: Fr::SZipper::AbstractCursor
Instance Method Summary
collapse
Methods included from Enumerable
#all?, #any?, #chunk, #collect, #collect_concat, #count, #cycle, #detect, #drop, #drop_while, #each, #entries, #filter, #filter_, #first, #flat_map, #foldl, #grep, #group_by, #include?, #index, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #partition, #reduce, #reject, #sort, #take, #take_while, #zip
Instance Method Details
#empty? ⇒ Boolean
22
23
24
|
# File 'lib/fr/szipper/abstract_cursor.rb', line 22
def empty?
false
end
|
41
42
43
44
45
|
# File 'lib/fr/szipper/abstract_cursor.rb', line 41
def head
cursor = self
cursor = cursor.prev until cursor.head?
cursor
end
|
#next(phantom = false) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/fr/szipper/abstract_cursor.rb', line 26
def next(phantom = false)
@__next ||= begin
if tail?
if phantom
TailNextCursor.new(self)
else
raise Errors::ZipperError,
"tail node has no next"
end
else
MemoizedCursor.new(node.next, self)
end
end
end
|
53
54
55
|
# File 'lib/fr/szipper/abstract_cursor.rb', line 53
def position
@prev.position + 1
end
|
47
48
49
50
51
|
# File 'lib/fr/szipper/abstract_cursor.rb', line 47
def tail
cursor = self
cursor = cursor.next until cursor.tail?
cursor
end
|
57
58
59
|
# File 'lib/fr/szipper/abstract_cursor.rb', line 57
def truncate
update(node.copy(next: nil))
end
|