Class: Fr::TZipper::RootCursor

Inherits:
AbstractCursor show all
Defined in:
lib/fr/tzipper/root_cursor.rb

Instance Attribute Summary collapse

Query the Tree Location collapse

Traversing the Tree collapse

Editing the Tree collapse

Instance Method Summary collapse

Methods inherited from AbstractCursor

#append_child, #between, #child, #children, #dangle, #descendant, #down, #flatten, #insert_left, #insert_right, #prepend_child

Constructor Details

#initialize(node) ⇒ RootCursor

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

#nodeAbstractNode (readonly)

Returns:

  • (AbstractNode)


7
8
9
# File 'lib/fr/tzipper/root_cursor.rb', line 7

def node
  @node
end

#pathAbstractPath (readonly)

Returns:



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

#deletevoid

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

#depthObject



21
22
23
# File 'lib/fr/tzipper/root_cursor.rb', line 21

def depth
  0
end

#firstObject



49
50
51
# File 'lib/fr/tzipper/root_cursor.rb', line 49

def first
  self
end

#first?Object



26
27
28
# File 'lib/fr/tzipper/root_cursor.rb', line 26

def first?
  true
end

#inspectObject



118
119
120
# File 'lib/fr/tzipper/root_cursor.rb', line 118

def inspect
  "Cursor(Root, #{@node.inspect})"
end

#lastObject



54
55
56
# File 'lib/fr/tzipper/root_cursor.rb', line 54

def last
  self
end

#last?Object



31
32
33
# File 'lib/fr/tzipper/root_cursor.rb', line 31

def last?
  true
end

#leaf?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/fr/tzipper/root_cursor.rb', line 36

def leaf?
  @node.leaf? or @node.children.empty?
end

#nextvoid

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

#prevvoid

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

#replace(node) ⇒ RootCursor

Returns:



104
105
106
# File 'lib/fr/tzipper/root_cursor.rb', line 104

def replace(node)
  RootCursor.new(node)
end

#rootRootCursor

Navigate to the root node

Returns:



74
75
76
# File 'lib/fr/tzipper/root_cursor.rb', line 74

def root
  self
end

#root?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/fr/tzipper/root_cursor.rb', line 41

def root?
  true
end

#upvoid

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