Is there any method or idea to get whole class into a text file ?
-------- Original-Nachricht --------
Datum: Fri, 26 Oct 2007 16:17:51 +0900
Von: Pokkai D. [email protected]
An: [email protected]
Betreff: whole class into a text file…
Is there any method or idea to get whole class into a text file ?
Posted via http://www.ruby-forum.com/.
Dear Pokkai,
maybe this
http://www.headius.com/rubyspec/index.php/Marshaling
is what you mean.
Best regards,
Axel
On 26 Oct 2007, at 16:17, Pokkai D. 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 G.
Bioinformatics Center
Kyoto University