rubyx icon indicating copy to clipboard operation
rubyx copied to clipboard

Longer Strings

Open rubydesign opened this issue 5 years ago • 0 comments

https://github.com/ruby-x/rubyx/blob/master/lib/parfait/word.rb

Strings are currently limited to i think 20 chars. This is starting to be a problem.

The solution is to have "extensions" (better naming welcome). This means when a string goes over the max, a new string should be created and linked into the original as an "extension" . The attribute next_word, where this extension should go, is already there.

The work is to make all the existing methods extension aware. Basic examples:

  • length needs to check extension and possibly add it
  • [] index operator needs to check if index is in extension and pass the request on

In effect the Word becomes a linked list, and that needs to be managed. As a reference, BinaryCode does a very similar thing https://github.com/ruby-x/rubyx/blob/master/lib/parfait/binary_code.rb

rubydesign avatar Mar 20 '20 07:03 rubydesign