Forum: Ruby to_yaml method

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F7ffbebbb463308298b1864ad0e9552e?d=identicon&s=25 Simon Rozet (Guest)
on 2007-04-07 17:28
(Received via mailing list)

In order to learn Ruby, I am trying to write a Getting Things Done
manager in Ruby+YAML.

So, here is where I am :
Be carefull... Store#to_yaml is realy ugly !
So, how can I make this method prettier ?

BTW, this is probably not the only ugly method... so feel free to
correct me, it'll
help me to learn the Ruby Way :-)

Thanks in advance,
7b4707f974af261f71943e1f2046c9ee?d=identicon&s=25 SonOfLilit (Guest)
on 2007-04-07 18:00
(Received via mailing list)
Check out for exactly this kind of

F7ffbebbb463308298b1864ad0e9552e?d=identicon&s=25 Simon Rozet (Guest)
on 2007-04-07 18:19
(Received via mailing list)
Thanks. I feel a bit uncomfortable with having a mentor (I don't know
exactly why... maybe that's too easy ?) but I'll try to contact a
mentor and see what happen :-)
BTW, the concept is realy interesting... IMHO having a mentor is the
best way to learn something. AFAIK I haven't seen project like this on
other porgramming language communauty.

2007/4/7, SonOfLilit <>:
7b4707f974af261f71943e1f2046c9ee?d=identicon&s=25 SonOfLilit (Guest)
on 2007-04-07 18:49
(Received via mailing list)
Thank you.

Don't be uncomfortable, the worst that could happen is nothing.

I agree that the concept is interesting and great, and I, too, think
it's original.

Hopefully you'll join the rank of mentors soon :)

96931bfe0c2948f47a98e15ae52e5637?d=identicon&s=25 Chris Carter (cdcarter)
on 2007-04-07 19:07
(Received via mailing list)
On 4/7/07, Simon Rozet <> wrote:
> >
> > > So, how can I make this method prettier ?
> > >
> >
> >
> --
> Simon Rozet,

A few style notes.  The multiple assignment you do "tasks, projects =," is usually done on two lines, just for
readability, and dropping some complexity.  Also you can just assign
to [], which gives you a blank array ({} for hashes).

    @projects.each_pair { |k, v| projects << v }
    @tasks.each_pair { |k, v| tasks << v }

Can be replaced with

    tasks = {|x| x }
    projects = {|x| x }

With this you can also drop the array initialization.  This method is
in the Enumerable module, which Hash and Array mixin.  You could even
make it just be

        dump = {|x| x }
        dump << {|x| x }
        return YAML.dump(dump)

Hope that helps you some!
084b13bebff6514ac50cd171c4e10e51?d=identicon&s=25 ChrisKaelin (Guest)
on 2007-04-08 00:55
(Received via mailing list)
On Apr 7, 5:27 pm, "Simon Rozet" <> wrote:
> correct me, it'll
> help me to learn the Ruby Way :-)
> Thanks in advance,
> --
> Simon Rozet,

Hey cool! A GTD application in ruby. I'm looking forward to see this
project on ;-)
This topic is locked and can not be replied to.