How to get the name of parent object inside child object?

how to get the name of parent object inside child object without passing
any

arguments to child object(global variable is not allowed) ?

i don’t know exactly what you mean, but…
Given object x try:

puts x.class.superclass

Raffaele Tesi wrote:

i don’t know exactly what you mean, but…
Given object x try:

puts x.class.superclass

class Cycle
@brand=“something”
def initialize
end
end
class Wheel
@brand
def option
Cycle.new
end
end

w=Wheel.new
@brand —>nil
w.option
@brand —>“something”

i need a requirement like above one example.

should not passing any arguments to child object(w.option)
global variable is not allowed.

something like this?

class Cycle
attr_accessor :brand
def initialize
@brand=“something”
end
end
class Wheel
def option
Cycle.new
end
end

w=Wheel.new
puts w.option.brand

thank for the quick reply

sorry i wrote wrong explanation
this is my correct explanation

class Cycle
@brand=nil
def initialize
end
end
class Wheel
@brand=“something”
def option
Cycle.new
end
end

w=Wheel.new
w.brand —>something
c=Cycle.new
c.brand —>nil

w.option.brand —>something

any idea ?