Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
How do you limit the line length of the output commands? Where ispqueue library documented?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="David Masover, post: 4649352"] There you go. If you run Ruby outside of SciTE, does that class exist? What does this do? I'm not aware of a 'retrieve' method in Ruby. Maybe you meant something like this: require 'pp' What I'd assumed, but can't find decent documentation for, is that pp can customize the output somewhat. When you run pp like this: pp foo.methods That expands to this: pp(foo.methods) So what you're really doing is trying to find: pp().methods Does that make any sense? In other words, you're treating pp like an object, which it's not. You're actually calling 'methods' on the return value of the _method_ pp, which returns nil for me. In other words, what you're doing is probably equivalent to looking at nil.methods. Probably true. It's not trivial to find out whether a method is inherited from within Ruby. I've been doing things like this, from the commandline: ri pp That, and otherwise looking at methods. Giant, gaping syntax error: Ruby doesn't really have keyword arguments. That's showing what the argument is called, and what its default value is -- in other words, it's showing how you might define it. So, you probably wanted: PP.pp(pq.methods, $> 60) This still won't do what you want, though -- it works well enough for arrays that fit on one line, but as soon as the array spans multiple lines, it shows one per line. And yes, reading the source, you do have to call PP.pp if you want to use those arguments. The normal 'pp' is a wrapper that just calls PP.pp on each of its arguments, which is why you got a '60' at the end. Sounds like exactly what you wanted. So what's the problem? What "display output class"? And why? Exactly. Why should this be part of the language, or even the standard library? Ruby is used in all sorts of places. It seems to be quite popular on the web, for example, where output is to a web browser which can clearly word-wrap for you. I can't remember ever wanting this feature. So, if it's useful to you, by all means, put it in a function, or find a library that serves your purpose. Or write one, make a gem, and share it with the world. But what you're suggesting makes no sense. Ruby doesn't have a "display output class". It has IO classes, which may or may not have anything to do with display. It also has bindings to various GUI and network libraries, which might be what it's using for display instead. I would suggest it's not really Ruby's job, nor is it necessarily even the job of the program you're writing. If you're on any sort of Unix, I'd suggest piping the output through the 'fold' command. If you're outputting to anything other than the terminal, there's a good chance that tool will support word-wrapping -- which is why I asked if you were using something like Notepad to view the output. Surely SCiTE should have some option to wrap long lines for you, if not on individual words. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
How do you limit the line length of the output commands? Where ispqueue library documented?
Top