is it possible to convert from a ruby object to Ruby class...
any idea.....
···
--
Posted via http://www.ruby-forum.com/.
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 Gutteridge
Bioinformatics Center
Kyoto University
On 10 Oct 2007, at 15:24, Pokkai Dokkai wrote:
is it possible to convert from a ruby object to Ruby class...
any idea.....
-- Posted via http://www.ruby-forum.com/\.
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
<manipulate obj>
instance = obj.new
Sylvain
On Wednesday 10 October 2007, Pokkai Dokkai wrote:
is it possible to convert from a ruby object to Ruby class...
any idea.....
Pokkai Dokkai wrote:
is it possible to convert from a ruby object to Ruby class...
any idea.....
do u mean this?
http://www.ruby-doc.org/core/classes/Object.html#M000348
--
Posted via http://www.ruby-forum.com/\.
Sylvain Joyeux wrote:
On Wednesday 10 October 2007, Pokkai Dokkai 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
<manipulate obj>
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 ?.
--
Posted via http://www.ruby-forum.com/\.
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.
On Oct 10, 2007, at 4:22 AM, Shai Rosenfeld wrote:
Pokkai Dokkai wrote:
is it possible to convert from a ruby object to Ruby class...
any idea.....do u mean this?
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 ......
--
Posted via http://www.ruby-forum.com/.
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
2007/10/10, Pokkai Dokkai <bad_good_lion@yahoo.com>:
Sylvain Joyeux wrote:
> On Wednesday 10 October 2007, Pokkai Dokkai 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
>
> <manipulate obj>
>
> instance = obj.new
>
> Sylvainsource code here
---------------------
class Name
def initialize
end
.....
end
-----------------------obj=Name.new
now my question is ,how to create above source code ?.
# AFAIK, this is not possible. Take a look at ruby2ruby
cool
# I'm guessing something like
From: Ari Brown [mailto:ari@aribrown.com]
#
# 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
# 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
From: Peña, Botp [mailto:botp@delmonte-phil.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
On Oct 10, 2007, at 5:50 AM, Pokkai Dokkai wrote:
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 formatso i am asking this question ......
-- Posted via http://www.ruby-forum.com/\.