On 26 Oct 2007, at 16:17, Pokkai Dokkai wrote:
> Is there any method or idea to get whole class into a text file ?
If you are still asking about this:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/273496
Then here is a start:
alexg@alexgdell:~/Desktop$ cat r2r.rb
require 'ruby2ruby'
class Foo
def bar(a)
return "foobar"
end
end
class Class
def to_ruby
str = "class #{self}\n"
self.instance_methods(false).each do |sym|
str << RubyToRuby.translate(self,sym.to_sym) + "\n"
end
str << "end\n"
end
end
puts Foo.to_ruby
alexg@alexgdell:~/Desktop$ ruby r2r.rb
class Foo
def bar(a)
return "foobar"
end
end
Alex Gutteridge
Bioinformatics Center
Kyoto University