DLLNode Gem Gem Version

Defines and implements a Doubly Linked List Node Abstract Data Structure and DLLNode class. A Node subclass. A DLLNode has a data attribute, a front attribute, and a back attribute. There is a DLLNode class and a DLLNodeHelper module. The class and the module contain eleven methods. Six methods are public DLLNode instance methods, three are private DLLNode instance methods, and two are helper methods.


Add this line to your application's Gemfile:

gem 'doubly_linked_list_node', '1.0.2'

And then execute:

$ bundle

Or install it yourself as:

$ gem install doubly_linked_list_node 


The DLLNode class subclasses Node, and represents a Doubly Linked List Node Abstract Data Structure. The data attribute stores the node's data, the front attribute refers the proceeding node, and the back attribute refers the preceding node. The attributes accept particular types. Operating unacceptable types raises errors.


  • DLLNode's acceptable data types are type String, Fixnum, Float, Complex, Time, Symbol, Bignum, and NilClass. All other types are unacceptable data types and raise errors.
  • The front and back attributes' acceptable objects are NilClass objects, and DLLNode objects. All other object type arguments raise errors.

Public instance methods

There are six public instance methods.

initialize(data_argument = nil, back_argument = nil, front_argument = nil)

The constructor. Takes three arguments. The arguments initialize the data, back, and front attributes. Calls the corresponding attribute setter methods. The argument default values are all nil.


Getter method. Gets the data attribute object reference and returns it.


Getter method. Gets the back attribute's DLLNode object reference and returns it.


Getter method. Gets the DLLNode object the front attribute refers and returns it.


The equality operator. Returns true in the case self and the argued node's attributes refer the same objects. Returns false otherwise. In the case the argument is any type excluding DLLNode, raises an ArgumentError.


Deeply copies self and returns the duplicate. Untested. Use carefully.

Private instance methods

There are three private instance methods.


Setter method. Sets the data attribute the argued object. Calls the verify_data_type(data_object) helper method, passing the argued data object. In the case the data object is an unacceptable type, raises an ArgumentError.


Setter method. Sets the back attribute the argued node's reference.


Setter method. Sets the front attribute the argued DLLNode reference.

Helper methods

There are two helper methods.


Boolean method. In the case the argument's type is unacceptable, raises an ArgumentError. Otherwise, returns true.


Boolean method. In the case the argument is a DLLNode, returns true. Otherwise raises an ArgumentError.


After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.


The class methods and the helper methods were basically tested. Further testing is necessary. One method, the deeply_dup() public instance method was untested.


Bug reports and pull requests are welcome on GitHub at https://github.com/scientist8202/DLLNode. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the DLLNode project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.