On 5/16/07, edlich / gmail.com <edlich / gmail.com> wrote:
> To start a new Ruby Project I need some more features that I know
> partially from Java:
>
> 1. Does Ruby support Annotations? Or is there another cool way to do
> this
> without changing the class itself?
> -> I need to tell reflection to do something special with the class.
>
> 2. Can I modify the getter of any instance var?!
> -> E.g. if an attribute defines attr_accessor, can I change the getter
> at
> runtime to do magic aspect stuff around the real get call?
>
> 3. Can we define new Keywords in Ruby?
> -> I am thinking of somthing like this: Define a block containing some
> real code and some useless keywords. Then I want to pass the block,
> e.g. convert it to_s and read the real code and the keywords.
> The keywords itself shall be ignored by ruby but can be parsed by me.
> (I always thought this would be a basic feature to build a DSL...
> but obviously real gurus can do without this...)
>
> 5. Is there a (free) UML modelling Tool for Ruby on the market?
> -> I need to have the architectural UML Overview!!
> (How do all the gbig ruby projects do this??)
>
> 6. I am missing the java toString method in Ruby.
> -> Isn't there an easy way to define an objects puts behaviour?

You're missing "to_s"

$ irb
irb> class Foo; end
=> nil
irb> Foo.new
=> #<Foo:0x1001380c>         <-- default stringification

irb> class Foo; def to_s; "a Foo"; end end
=> nil
irb> Foo.new
=> a Foo                  <-- customized stringification

irb> quit

> Thanks in advance
> (and thanks for the cool language Matz!)
>
> Stefan Edlich
>
>
>