Forum: Ruby Columnization of text, using text-reform

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sy Ali (Guest)
on 2006-05-15 05:26
(Received via mailing list)
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
[2] 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
Sy Ali (Guest)
on 2006-05-15 05:56
(Received via mailing list)
On 5/14/06, Sy Ali <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..
Sy Ali (Guest)
on 2006-05-15 06:24
(Received via mailing list)
On 5/14/06, Sy Ali <removed_email_address@domain.invalid> wrote:
> On 5/14/06, Sy Ali <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

The examples aren't quite working as-expected.. but I'm muddling through
it all.
Sy Ali (Guest)
on 2006-05-16 04:38
(Received via mailing list)
On 5/14/06, Sy Ali <removed_email_address@domain.invalid> wrote:
> I'm playing with this 'classes' stuff:
> 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
This topic is locked and can not be replied to.