Class: Fr::SZipper::TailNextCursor

Inherits:
AbstractCursor show all
Defined in:
lib/fr/szipper/tail_next_cursor.rb

Instance Method Summary collapse

Methods inherited from AbstractCursor

#head, #position, #truncate

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

Constructor Details

#initialize(prev) ⇒ TailNextCursor

Returns a new instance of TailNextCursor.



5
6
7
# File 'lib/fr/szipper/tail_next_cursor.rb', line 5

def initialize(prev)
  @prev = prev
end

Instance Method Details

#append(node) ⇒ Object



38
39
40
# File 'lib/fr/szipper/tail_next_cursor.rb', line 38

def append(node)
  @prev.append(node)
end

#deleteObject



58
59
60
# File 'lib/fr/szipper/tail_next_cursor.rb', line 58

def delete
  @prev
end

#empty?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/fr/szipper/tail_next_cursor.rb', line 9

def empty?
  true
end

#head?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fr/szipper/tail_next_cursor.rb', line 17

def head?
  false
end

#inspectObject



62
63
64
# File 'lib/fr/szipper/tail_next_cursor.rb', line 62

def inspect
  "Cursor([..., #{@prev.node.inspect}, ___])"
end

#next(phantom = false) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/fr/szipper/tail_next_cursor.rb', line 29

def next(phantom = false)
  if phantom
    self
  else
    raise Errors::ZipperError,
      "tail node has no next"
  end
end

#prepend(node) ⇒ Object



42
43
44
# File 'lib/fr/szipper/tail_next_cursor.rb', line 42

def prepend(node)
  @prev.append(node)
end

#prev(phantom = false) ⇒ Object



25
26
27
# File 'lib/fr/szipper/tail_next_cursor.rb', line 25

def prev(phantom = false)
  @prev
end

#replace(node) ⇒ Object



54
55
56
# File 'lib/fr/szipper/tail_next_cursor.rb', line 54

def replace(node)
  EditedCursor.new(node, @prev)
end

#tailObject



21
22
23
# File 'lib/fr/szipper/tail_next_cursor.rb', line 21

def tail
  @prev
end

#tail?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/fr/szipper/tail_next_cursor.rb', line 13

def tail?
  false
end

#update(node = nil) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/fr/szipper/tail_next_cursor.rb', line 46

def update(node = nil)
  if node.nil?
    @prev.append(yield(nil).copy(next: nil))
  else
    @prev.append(node.copy(next: nil))
  end
end