is it possible to convert from a ruby object to Ruby class…
any idea…
Pokkai D. wrote:
is it possible to convert from a ruby object to Ruby class…
any idea…
do u mean this?
On 10 Oct 2007, at 15:24, Pokkai D. wrote:
is it possible to convert from a ruby object to Ruby class…
any idea…Posted via http://www.ruby-forum.com/.
I’m not sure what you mean, but every Object has a class method which
gives you it’s class.
irb(main):008:0> 1.class
=> Fixnum
irb(main):009:0> ‘foo’.class
=> String
Alex G.
Bioinformatics Center
Kyoto University
On Wednesday 10 October 2007, Pokkai D. wrote:
is it possible to convert from a ruby object to Ruby class…
any idea…
What do you exactly have in mind ? Ruby classes are already Ruby
objects … so if you need to manipulate classes as objects you already
can
obj = Class.new
instance = obj.new
Sylvain
Sylvain J. wrote:
On Wednesday 10 October 2007, Pokkai D. wrote:
is it possible to convert from a ruby object to Ruby class…
any idea…
What do you exactly have in mind ? Ruby classes are already Ruby
objects … so if you need to manipulate classes as objects you already
canobj = Class.new
instance = obj.new
Sylvain
source code here
class Name
def initialize
end
…
end
obj=Name.new
now my question is ,how to create above source code ?.
source code here
class Name
def initialize
end
…
end
obj=Name.new
now my question is ,how to create above source code from obj?.
actually jruby will create java object to ruby object
but that ruby object(from java object) is not in source code format
so i am asking this question …
2007/10/10, Pokkai D. [email protected]:
…
endobj=Name.new
now my question is ,how to create above source code ?.
If you want to create the class definition source code when having an
instance only there is no way - at least no standard way. You would
have to dig into the Ruby interpreter to do that.
robert
On Oct 10, 2007, at 4:22 AM, Shai R. wrote:
Pokkai D. wrote:
is it possible to convert from a ruby object to Ruby class…
any idea…do u mean this?
Maybe he means something like extracting Ruby code for the class out
of the object… That would be very interesting, because you could
really delve in and affect all sorts of bug fixes for compiled
extensions.
AFAIK, this is not possible. Take a look at ruby2ruby
I’m guessing something like
a = YourClass.new
a.to_ruby
Ari
--------------------------------------------|
If you’re not living on the edge,
then you’re just wasting space.
From: Peña, Botp [mailto:[email protected]]
arggh, i’m feeling dumb, i’ve just downloaded the gem, but i
do not know how to require it. The rdoc does not give an example.
pls ignore. dumb indeed. forgot the ‘rubygems’ require. gotta change my
irb ini.
my next question is, will this run on windows?
if yes, examples pls.
thanks and kind regards -botp
On Oct 10, 2007, at 5:50 AM, Pokkai D. wrote:
now my question is ,how to create above source code from obj?.
actually jruby will create java object to ruby object
but that ruby object(from java object) is not in source code formatso i am asking this question …
Posted via http://www.ruby-forum.com/.
Well, it could be sort of possible, but partly pointless:
You could start a ruby process that then loads a file, but before
loading, read the file. You could then create objects that contain
the code (as a string, probably) for classes in the original file.
Then when you ask an object, “what class are you?”, you will have a
little clipboard (or PDA) to lookup his/her class name and fetch your
class_code string.
From there it would be possible to alter the class_code string, then
re"load" that class into the interpreter…
circular? could be
pointless? maybe
fun? probably
From: Ari B. [mailto:[email protected]]
AFAIK, this is not possible. Take a look at ruby2ruby
cool
I’m guessing something like
a = YourClass.new
a.to_ruby
arggh, i’m feeling dumb, i’ve just downloaded the gem, but i do not know
how to require it. The rdoc does not give an example.
kind regards -botp