How to get the variables from a class

I have this code:


require ‘appliances’
class Toast<Appliances
def toast(hole,size,seconds,quantity)
self.turn_on(seconds,quantity)
self.chooser(hole,size)
end
end

And from another file:


require ‘toast’
tuest1=::toast.new(‘white’,‘big’) # from Appliances
tuest1.buy(‘Bread’,‘10’) # from Appliances
tuest1.toast(‘1’,‘200’,‘120’,‘2’)

Now I want to create a new variable that automatically has the same
values (‘1’,‘200’,‘120’,‘2’ in this case) than the variable tuest1 in
tostar:

tuest2.toast=tuest1.toast

But it doesn’t work.

Anybody knows how can I do it?

Thank you.

I forgot it, before I did tuest2.toast=tuest1.toast I did:

tuest2=::toast.new(‘black’,‘biggest’) # from Appliances

The error is:
wrong number of arguments

On Nov 1, 2007, at 12:24 PM, Mario R. wrote:


Now I want to create a new variable that automatically has the same
values (‘1’,‘200’,‘120’,‘2’ in this case) than the variable tuest1 in
tostar:

tuest2.toast=tuest1.toast

You don’t show enough code for me to do more than make a guess, but
providing

tuest1=::toast.new('white','big')

is really a typo for

tuest1=Toast.new('white','big')

and providing Toast#initialize along with Appliance#buy and
Toast#toast have set up all the instance variables properly, then

tuest2 = tuest1.dup

should do it.

Regards, Morton