From: Tobias Reif Date: 2002-01-12T19:59:17+09:00 Subject: Re: MetaRuby : RubySchema.rb howto? Mathieu Bouchard wrote: > There is no un-parsing back to Ruby, yet. I want that for next version > though. sounds good! > I'm making incompatible changes to it about right now. Its main current > purpose is that interested people can look at it and suggest > changes. to_s, but something like that seems to be on your list already. > OTOH, the best way you can find out what to suggest is to try to > write real programs using it. I am. For example, I'm writing a program that's generating Ruby code. It works, but some code could be made much cleaner by using objects representing the components of the program to be generated. So where I now have a mess of spaces, newlines, strings etc. def make_getter attr_name meth_name = to_methodname(attr_name) "\n def #{meth_name}\n"+ " @attributes['#{attr_name}'].to_s.to_number\n"+ " end\n" end , I'd like to write something like def make_getter attr_name DefMethod.new(...) # ... end , then serialize that (plus more stuff) to pretty printed Ruby code to a file. But if I understand you correctly, serializing to actual Ruby code (to_s) is not yet implemented, so 'm going to wait for the next version. > DefClass is broken in 0.7; the "Any.of" was supposed to be on the next > line. (Any.of is only useful with at least 2 args) I see; I'm looking forward to the next release. > You won't be able to do that. ClassDefs don't contain methods directly, > they contain MethodDefs (or not) instead. When you will eval why not "to_s"? (Or did I get something wrong here) > Many of the future changes to RubySchema will be introduced in part to > reduce verboseness like body.body and [[]] and so on... Sounds good; Ease of use would be my greatest wish :) Tobi -- http://www.pinkjuice.com/