I have the following problem. I would like to have a method, let's call it method_A that check the object name that call method_A.
This is a simple reference, but what I'd be doing would be much more complicated than this, I understand that there's an alternative that can solve what I need in a much better way, but alas the code almost done, and I don't have enough time to tweak around much. Anyway, here it goes:
class Picture
attr_accessor :size
def resize
name = self.get_object_name_here
case name
when Big #Can be string or variable, I don't mind
self.size *= .5
when Medium
when Small
self.size *= 2
else
end
def get_object_name_here
object_name
end
end
Big = Picture.new
Medium = Picture.new
Small = Picture.new
Big.size = 10
Medium.size = 10
Small.size = 10
Big.resize => 5
Medium.resize => 10
Small.resize => 20
If there's a way to just do
name = object_name
That would be very HELPFUL
Greatly Appreciated!
Edit: Sorry for the capitalized Big, Medium, Small. They are typos.
object_name? In your example would they beBig, Medium and Small?Pictureobjects: it is impossible for thePictureknow which variable you are using.