Ask a Question related to Ruby, Design and Development.
-
Ed Baker #1
Tanaka Akira's PrettyPrint usage? Are there any examples?
I'm interested in using the prettyprint module available from RAA.
But, as a relatively new Rubyist, I can't seem to make sense of the included RDOCS.
Has anyone got some simple examples they could share?
Ed Baker Guest
-
Using examples
I am new to flex and have purchased a few components with examples. What are the step by step instructions for using the projects within Flex.... -
Examples for Feb CTP
Hi people! I have visit the page ... -
ASP Flex examples
I'm not huge on ASP VBScript, but I do have a requirement to get an example together of the Shopping Cart example working with MXML and Flex Builder... -
learning examples
I am following an online study to learn Perl. I wrote my first 2 programs and run them but unable to find what's wrong with them. the first is as... -
HTMLRendering examples?
In article <r.ortega-796F48.10383521052003@news.speakeasy.net>, Raoul Ortega <r.ortega@mouse-potato.com> wrote: Of course, if you can assume a... -
why the lucky stiff #2
Re: Tanaka Akira's PrettyPrint usage? Are there any examples?
I have a brief explanation on WS&NiR (towards the bottom of the page):
[url]http://whytheluckystiff.net/articles/2003/08/04/rubyOneEightOh[/url]
Anything in particular you want to know?
_why
On Thursday 04 September 2003 05:25 am, Ed Baker wrote:> I'm interested in using the prettyprint module available from RAA.
>
> But, as a relatively new Rubyist, I can't seem to make sense of the
> included RDOCS.
>
> Has anyone got some simple examples they could share?
why the lucky stiff Guest
-
Ed Baker #3
Re: Tanaka Akira's PrettyPrint usage? Are there any examples?
Without sounding incredibly stupid, I want to know how to feed it ruby code and
get back formatted output.
I sort of expected a unix like sytax. i.e. a command line like:
ruby pp.rb myfile.rb > mynewfile.rb
why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote in message news:<200309041108.51867.ruby-talk@whytheluckystiff.net>...> I have a brief explanation on WS&NiR (towards the bottom of the page):
>
> [url]http://whytheluckystiff.net/articles/2003/08/04/rubyOneEightOh[/url]
>
> Anything in particular you want to know?
>
> _why
>
> On Thursday 04 September 2003 05:25 am, Ed Baker wrote:> > I'm interested in using the prettyprint module available from RAA.
> >
> > But, as a relatively new Rubyist, I can't seem to make sense of the
> > included RDOCS.
> >
> > Has anyone got some simple examples they could share?Ed Baker Guest
-
Ed Baker #4
Re: Tanaka Akira's PrettyPrint usage? Are there any examples?
Also, did I make a mistake in downloading the pp application from RAA?
Since it's supposed to be a builtin to v1.8. Should I have left well enough
alone?
It's like what carburetor means in French: "If it works, don't touch it"
why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote in message news:<200309041108.51867.ruby-talk@whytheluckystiff.net>...> I have a brief explanation on WS&NiR (towards the bottom of the page):
>
> [url]http://whytheluckystiff.net/articles/2003/08/04/rubyOneEightOh[/url]
>
> Anything in particular you want to know?
>
> _why
>
> On Thursday 04 September 2003 05:25 am, Ed Baker wrote:> > I'm interested in using the prettyprint module available from RAA.
> >
> > But, as a relatively new Rubyist, I can't seem to make sense of the
> > included RDOCS.
> >
> > Has anyone got some simple examples they could share?Ed Baker Guest
-
Jason Creighton #5
Re: Tanaka Akira's PrettyPrint usage? Are there any examples?
On 4 Sep 2003 04:10:32 -0700
[email]ejb@theworld.com[/email] (Ed Baker) wrote:
prettyprint is now included in Ruby, at least as of 1.8. Just from> I'm interested in using the prettyprint module available from RAA.
>
> But, as a relatively new Rubyist, I can't seem to make sense of the
> included RDOCS.
>
> Has anyone got some simple examples they could share?
reading the commands in prettyprint.rb, it appears prettyprint is a
module for building, well, pretty printers.
I can't share any examples for prettyprint, but I can share some for
'pp', a library which builds upon prettyprint to provide nice output for
Ruby objects. For example:
=> true>> require 'pp'=> [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], [0, 4, 8, 12, 16]]>> ary = Array.new(5) { |i| Array.new(5) { |j| i*j } }[[0, 0, 0, 0, 0],>> pp ary
[0, 1, 2, 3, 4],
[0, 2, 4, 6, 8],
[0, 3, 6, 9, 12],
[0, 4, 8, 12, 16]]
=> nil[["PWD", "/usr/lib/ruby/1.8"],>> pp ENV.select { |k,v| k.length == 3 }
["PS1", "\\w\\$ "],
["PS2", "> "],
["XWM", "ion"]]
=> nil
....and so on. YAML can help pretty-print as well:
--->> h = {}; 5.times { |i| h[i] = i**4 }; puts h.to_yaml
0: 0
1: 1
2: 16
3: 81
4: 256
=> nil
YAML defines a 'y' method that's shorthand for puts obj.to_yaml, ie:
=> {"goober"=>"lala", 3.1415=>"PI", 123=>456}>> h = { "goober" => "lala", 123 => 456, 3.1415 => "PI" }--->> y h
goober: lala
3.1415: PI
123: 456
=> nil
Fun stuff.
Jason Creighton
Jason Creighton Guest
-
why the lucky stiff #6
Code beautifier (was Re: Tanaka Akira's PrettyPrint usage? Are there any examples?)
Ed Baker (ejb@theworld.com) wrote:
If you run pp.rb from the commandline, the library will perform some>
> I sort of expected a unix like sytax. i.e. a command line like:
> ruby pp.rb myfile.rb > mynewfile.rb
>
basic tests to ensure it is working. Oh, wait a sec. I see what you're
thinking. You're looking for something like lint, for beautifying Ruby
code.
PP is for displaying data structures in Ruby, so it won't do the trick.
Not sure what will.
_why
why the lucky stiff Guest



Reply With Quote

