[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

to_yaml method

Simon Rozet

4/7/2007 3:28:00 PM

Hello,

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

So, here is where I am : http://pastie.cabo...
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,

--
Simon Rozet, http://purl.o...

5 Answers

SonOfLilit

4/7/2007 3:59:00 PM

0

Check out http://RubyMentor.ru... for exactly this kind of help/advice.


Aur

On 4/7/07, Simon Rozet <simon.rozet@gmail.com> wrote:
> Hello,
>
> In order to learn Ruby, I am trying to write a Getting Things Done
> manager in Ruby+YAML.
>
> So, here is where I am : http://pastie.cabo...
> 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,
>
> --
> Simon Rozet, http://purl.o...
>
>

Simon Rozet

4/7/2007 4:18:00 PM

0

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 <sonoflilit@gmail.com>:
> Check out http://RubyMentor.ru... for exactly this kind of help/advice.
>
>
> Aur
>
> On 4/7/07, Simon Rozet <simon.rozet@gmail.com> wrote:
> > Hello,
> >
> > In order to learn Ruby, I am trying to write a Getting Things Done
> > manager in Ruby+YAML.
> >
> > So, here is where I am : http://pastie.cabo...
> > 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,
> >
> > --
> > Simon Rozet, http://purl.o...
> >
> >
>
>


--
Simon Rozet, http://aton...

SonOfLilit

4/7/2007 4:49:00 PM

0

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 :)


Aur

On 4/7/07, Simon Rozet <simon.rozet@gmail.com> wrote:
> 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 <sonoflilit@gmail.com>:
> > Check out http://RubyMentor.ru... for exactly this kind of help/advice.
> >
> >
> > Aur
> >
> > On 4/7/07, Simon Rozet <simon.rozet@gmail.com> wrote:
> > > Hello,
> > >
> > > In order to learn Ruby, I am trying to write a Getting Things Done
> > > manager in Ruby+YAML.
> > >
> > > So, here is where I am : http://pastie.cabo...
> > > 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,
> > >
> > > --
> > > Simon Rozet, http://purl.o...
> > >
> > >
> >
> >
>
>
> --
> Simon Rozet, http://aton...
>
>

Chris Carter

4/7/2007 5:07:00 PM

0

On 4/7/07, Simon Rozet <simon.rozet@gmail.com> wrote:
> 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 <sonoflilit@gmail.com>:
> > Check out http://RubyMentor.ru... for exactly this kind of help/advice.
> >
> >
> > Aur
> >
> > On 4/7/07, Simon Rozet <simon.rozet@gmail.com> wrote:
> > > Hello,
> > >
> > > In order to learn Ruby, I am trying to write a Getting Things Done
> > > manager in Ruby+YAML.
> > >
> > > So, here is where I am : http://pastie.cabo...
> > > 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,
> > >
> > > --
> > > Simon Rozet, http://purl.o...
> > >
> > >
> >
> >
>
>
> --
> Simon Rozet, http://aton...
>
>

A few style notes. The multiple assignment you do "tasks, projects =
Array.new, Array.new" 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 = @tasks.map {|x| x }
projects = @projects.map {|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 = @tasks.map {|x| x }
dump << @projects.map {|x| x }
return YAML.dump(dump)

Hope that helps you some!

--
Chris Carter
concentrationstudios.com
brynmawrcs.com

ChrisKaelin

4/7/2007 10:54:00 PM

0

On Apr 7, 5:27 pm, "Simon Rozet" <simon.ro...@gmail.com> wrote:
> Hello,
>
> In order to learn Ruby, I am trying to write a Getting Things Done
> manager in Ruby+YAML.
>
> So, here is where I am :http://pastie.cabo...
> 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,
>
> --
> Simon Rozet,http://purl.o...

Hey cool! A GTD application in ruby. I'm looking forward to see this
project on rubyforge.org ;-)