From: Mason Kelsey Date: 2009-09-25T01:59:13+09:00 Subject: Re: How do you limit the line length of the output commands? Where is pqueue library documented? --0016e64f69ec186617047455c098 Content-Type: text/plain; charset=ISO-8859-1 Thanks for the link to documentation on PQueue. If you maintain the link you might want to make it clear in the description that you can order ascending OR descending in the priority queue, and that any component (subarray) of the array can be used to sort/prioritize on. This automatic feature is of use in a lot of different applications. In my code I am adding elements in an ascending order on the first subarray, the heuristic value created by another method. My code is: pq=PQueue.new(proc{|x,y| x[0][0]*<*y[0][0]}) but if I had wanted descending order I would have written pq=PQueue.new(proc{|x,y| x[0][0]*>*y[0][0]}). Note the change from "<" to ">". And if I had wanted to sort on different subarray I would have changed the values in the brackets accordingly, just making sure that the x and y values were the same. Would be nice to have minor sort capabilities too in some applications. I also recommend that all Ruby documentation include simple real code examples of their use by including actual code that has been tested, with all the essential components included in the example. No Sam On Thu, Sep 24, 2009 at 10:03 AM, trans wrote: > > > On Sep 23, 5:59 pm, Mason Kelsey wrote: > > There must be an easy way to solve the problem of controlling the length > of > > the output line, forcing the rest into a line break. In the puts code > > example below, I want to break between every 10 methods or just go to a > new > > line after every 60 characters that get displayed so they don't run off > the > > screen. > > > > First Question: What is an easy way to modify the below puts code to > control > > line length without truncation? > > > > require "pqueue" > > pq=PQueue.new(proc{|x,y| x[0][0] > puts pq.methods.join(', ') # Displays the methods of PQueue Class > > > > I've a tried puts, print, and p and they never do a word wrap or such. > Is > > there a secret parameter for controlling the line length before word wrap > > occurs in these commands? > > > > Second question: The pqueue library is not documented inhttp:// > www.ruby-doc.org/stdlib/. Is there a > > reason for that? Or is it cleverly hidden in a class that doesn't seem > to > > have anything to do with priority queues? > > I've been transitioning to GitHub, and thanks to your question, this > morning I got the Grancher plugin for my build system running, so now > you can find it here: > > http://rubyworks.github.com/pqueue/ > > Thanks, > T. > > --0016e64f69ec186617047455c098--