E
Erick Star
Hi, I was wondering if it was possible to do something like the
following:
class A
def b
stuff
end
def c
stuff
end
def d(x)
self.x
end
end
Then use thing.d(a) with thing an instance of A?
Basically, given a long list of methods belonging to a class, if you
wanted ruby to apply methods based on the state of the program, how
would you set it up besides doing:
case A
when b
thing.stuff
when c
thing.otherstuff
following:
class A
def b
stuff
end
def c
stuff
end
def d(x)
self.x
end
end
Then use thing.d(a) with thing an instance of A?
Basically, given a long list of methods belonging to a class, if you
wanted ruby to apply methods based on the state of the program, how
would you set it up besides doing:
case A
when b
thing.stuff
when c
thing.otherstuff