# Columnization of text, using text-reform

**URL:** <https://www.ruby-forum.com/t/columnization-of-text-using-text-reform/94798>\
**Category:** Ruby\
**Created:** [May 15, 2006, 3:26am UTC](https://www.ruby-forum.com/t/columnization-of-text-using-text-reform/94798 "2006-05-15T03:26:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sy\_Ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Sy\_Ali](https://www.ruby-forum.com/u/Sy_Ali)\
**Post date:** [May 15, 2006, 3:26am UTC](https://www.ruby-forum.com/t/columnization-of-text-using-text-reform/94798/1 "2006-05-15T03:26:10Z")

</div>

Ok, I got text-hyphen and text-reform installed[1], and I looked at  
the test case for text-reform. Yes, that’s a great way to start  
learning stuff.

I also found a way to adapt it to my uses![2] This is a major  
victory. Except…

I have no idea how to break it free from test/unit

It has to do with these two things, I’m sure of it. I know they set  
up the r. in the r.format statements… but I don’t know what’s going  
on, what they’re called or how to learn more about them. =)

attr\_reader :r  
@r = Text::Reform.new

[1] [http://rubyforge.org/frs/?group\_id=294](http://rubyforge.org/frs/?group_id=294)  
[2] [Register4Less.com Parking Page for jrandomhacker.info](http://jrandomhacker.info/Sls)

The working script is:

$LOAD\_PATH.unshift “…/lib” if **FILE** == $0

require ‘test/unit’  
require ‘text/reform’

class Test\_\_Text\_Reform \< Test::Unit::TestCase

attr\_reader :r  
def setup  
@r = Text::Reform.new  
end

def test\_abiglongtext

filename1 = “This is a long filename”  
description1 = “desc”  
filename2 = “Filename”  
description2 = “This is a long description”  
filename3 = “This is a long filename”  
description3 = “This is a particularly long description”

output = “”  
output \<\< “------------------------\n”  
output \<\< r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename1, description1)  
output \<\< “------------------------\n”  
output \<\< r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename2, description2)  
output \<\< “------------------------\n”  
output \<\< r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename3, description3)  
output \<\< “------------------------\n”

puts output

```
end

```

end

---

<div class="post-metadata">

**Author:** ![Sy\_Ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Sy\_Ali](https://www.ruby-forum.com/u/Sy_Ali)\
**Post date:** [May 15, 2006, 3:56am UTC](https://www.ruby-forum.com/t/columnization-of-text-using-text-reform/94798/2 "2006-05-15T03:56:55Z")

</div>

On 5/14/06, Sy Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have no idea how to break it free from test/unit

Hmm… maybe I need to do some more exploring… I can’t run this script  
outside of the test suite. Bleh…

---

<div class="post-metadata">

**Author:** ![Sy\_Ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Sy\_Ali](https://www.ruby-forum.com/u/Sy_Ali)\
**Post date:** [May 15, 2006, 4:24am UTC](https://www.ruby-forum.com/t/columnization-of-text-using-text-reform/94798/3 "2006-05-15T04:24:40Z")

</div>

On 5/14/06, Sy Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 5/14/06, Sy Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I have no idea how to break it free from test/unit
> 
> Hmm… maybe I need to do some more exploring… I can’t run this script  
> outside of the test suite. Bleh…

Ok, I got it. The remote and local gems were failing to install, and  
my playing was using the live reform.rb as a fallback. To install it,  
I had to get the tarball and do

ruby install.rb --no-ri

Now back to my original problem. =)

I’m playing with this ‘classes’ stuff:  
[http://www.rubycentral.com/book/tut\_classes.html](http://www.rubycentral.com/book/tut_classes.html)

The examples aren’t quite working as-expected… but I’m muddling through  
it all.

---

<div class="post-metadata">

**Author:** ![Sy\_Ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Sy\_Ali](https://www.ruby-forum.com/u/Sy_Ali)\
**Post date:** [May 16, 2006, 2:38am UTC](https://www.ruby-forum.com/t/columnization-of-text-using-text-reform/94798/4 "2006-05-16T02:38:48Z")

</div>

On 5/14/06, Sy Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m playing with this ‘classes’ stuff:  
> [http://www.rubycentral.com/book/tut\_classes.html](http://www.rubycentral.com/book/tut_classes.html)
> 
> The examples aren’t quite working as-expected… but I’m muddling through it all.

Ok, I figured it out. I’m not sure why it works or what’s going on,  
but I’ll leave that for later. 😉

require ‘reform.rb’  
r = Text::Reform.new

filename1 = “This is a long filename”  
description1 = “desc”  
filename2 = “Filename”  
description2 = “This is a long description”  
filename3 = “This is a long filename”  
description3 = “This is a particularly long description”

output = “”  
output \<\< “------------------------\n”  
output \<\< r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename1, description1)  
output \<\< “------------------------\n”  
output \<\< r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename2, description2)  
output \<\< “------------------------\n”  
output \<\< r.format(“[[[[[[[[[[[ [[[[[[[[[[[”, filename3, description3)  
output \<\< “------------------------\n”

puts output
