Implementation

Class: NodeAdapter.

Constants

Attributes

back

A backward reference. Either a NodeAdapter or a NilClass instance.

data

A DataType type instance reference.

front

A forward reference. Either a NodeAdapter or a NilClass instance.

Methods

initialize(n = nil)

def initialize(n = nil)
unless (n.instance_of?(Node))
raise(ArgumentError, "#{n} is not a Node instance.")
else
self.back = n.back_ref()
self.data = n.data()
self.front = n.front_ref()
end
end

Initializes a NodeAdapter. Takes an argument Node, n. Sets back, data, and front n's back, data, and front. Returns a NodeAdapter instance. In the case n is not a Node instance, raises an ArgumentError.

back()

def back()
return @back
end

Gets back's reference. Returns the NodeAdapter or NilClass instance reference.

front()

def front()
return @front
end

Gets front's reference. Returns the NodeAdapter or NilClass instance reference.

attach_back(n = nil)

def attach_back(n = nil)
unless (n.instance_of?(NodeAdapter))
raise(ArgumentError, "#{n} is not a NodeAdapter instance.")
else
self.back = n
return nil
end
end

Attaches back a NodeAdapter. Takes a NodeAdapter argument, n. n becomes back's setting. Returns nil.

attach_front(n = nil)

def attach_front(n = nil)
unless (n.instance_of?(NodeAdapter))
raise(ArgumentError, "#{n} is not a NodeAdapter instance.")
else
self.front = n
return nil
end
end

Attaches front the argument NodeAdapter. Takes an argument NodeAdapter, n. n becomes front's setting. Returns nil.

detach_back()

def detach_back()
self.back = nil
end

Sets back nil. Returns nil.

detach_front()

def detach_front()
self.front = nil
end

Sets front nil. Returns nil.

back=(n = nil) private

def back=(n = nil)
@back = n
end

Sets back's reference. Takes an argument NodeAdapter or NilClass instance, n. n becomes back's setting. Returns the argument. Raises an ArgumentError in the case n is any type other than NodeAdapter or NilClass.

front=(n = nil) private

def front=(n = nil)
@front = n
end

Sets front's reference. Takes an argument NodeAdapter or NilClass instance, n. n becomes front's setting. Returns the argument. Raises an ArgumentError in the case n is any type other than NodeAdapter or NilClass.