Class: Rope::BasicNode

Inherits:
Object
  • Object
show all
Defined in:
lib/rope/basic_node.rb

Direct Known Subclasses

InteriorNode, LeafNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#depthObject (readonly)

Depth of the tree



7
8
9
# File 'lib/rope/basic_node.rb', line 7

def depth
  @depth
end

#lengthObject (readonly)

Length of the underlying data in the tree and its descendants



4
5
6
# File 'lib/rope/basic_node.rb', line 4

def length
  @length
end

Instance Method Details

#+(other) ⇒ Object

Concatenates this tree with another tree (non-destructive to either tree)



11
12
13
# File 'lib/rope/basic_node.rb', line 11

def +(other)
  InteriorNode.new(self, other)
end

#rebalance!Object

Rebalances this tree

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/rope/basic_node.rb', line 26

def rebalance!
  raise NotImplementedError
end

#replace!(index, length, rhs) ⇒ Object

Swaps out the data in this node to be rhs. Must be same length

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/rope/basic_node.rb', line 31

def replace!(index, length, rhs)
  raise NotImplementedError
end

#segment(index) ⇒ Object

Returns the Node that contains this index or nil if the index is out of bounds

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/rope/basic_node.rb', line 21

def segment(index)
  raise NotImplementedError
end

#to_primitiveObject

Gets the string representation of the underlying data in the tree



16
17
18
# File 'lib/rope/basic_node.rb', line 16

def to_primitive
  data
end