Topic: PDF::Writer Plugin

I'm hoping to turn some things into a pdf and I think pdf-writer is the way to do that.  However I haven't been able to find the correct link to the svn anywhere.  Has anyone installed this plugin using scripts/plugin install?

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: PDF::Writer Plugin

I am pretty sure it is a Gem not a plugin

Re: PDF::Writer Plugin

I've installed the gem, but there is supposed to be a plugin that makes ActionController recognize .rpdf template extentions.  The homepage of the railspdfplugin is [link url=http://rubyforge.org/projects/railspdfplugin/]here[/link]  I just can't figure out how to install the darn thing, even though I've seen serveral one line bits of code on the web.  Here's a oneliner if you can figure out how it's wrong:

ruby script/plugin install svn://rubyforge.org//var/svn/railspdfplugin/railspdf/

I get a "svn: command not found" error when trying it.

Last edited by circuitshaman (2006-07-18 10:43:47)

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: PDF::Writer Plugin

Do you have svn installed on your computer?

Re: PDF::Writer Plugin

DOH!  Thanks for pointing out my stupid mistake.  And thank you emerge for your quick fixes.  If I could abuse your time for just another moment, how does one execute a function on all the values in an array in ruby?  For instance:  Let's say I have an array full of numbers and I want them all to be converted to string?

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: PDF::Writer Plugin

You would do something like:

[6,4,6,7,4,2,7,0].each do |array|
array.to_s
end

Last edited by cdcarter (2006-07-18 12:34:23)

Re: PDF::Writer Plugin

If you want to convert the elements of an array (such as from a number to a string) in place, use "collect!" (or "map!") like this:

nums = [1, 2, 3]
nums.collect! { |n| n.to_s }
nums # => ["1", "2", "3"]

Railscasts - Free Ruby on Rails Screencasts

Re: PDF::Writer Plugin

But lets say I have a method that takes a number and performs some opperation on it.  What's the general rule for performing functions on array elements?  do I use each and call the function on each of the |variable|s? Or is there a quicker primitive operator for doing that in ruby, ie syntactic sugar for using a block?

Just curious.  Blocks seem pretty quick and readable as they are.

Last edited by circuitshaman (2006-07-18 13:33:56)

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: PDF::Writer Plugin

Actually there is a way which is a bit quicker, but if you are new to Ruby I'd suggest sticking with blocks. You can do this instead of writing out the block:

nums = [1, 2, 3]
nums.collect!(&:to_s)
nums # => ["1", "2", "3"]

The "&:to_s" just basically says "call to_s on the object passed into the block". It is a shortcut so you don't have to write out the blocks. Keep in mind, this isn't in the Ruby core yet (coming in 1.9 supposedly) but it is in the Rails core, so use script/console if you want to test it out (not irb).

Railscasts - Free Ruby on Rails Screencasts