From: Sateesh Kambhamapati Date: 2010-06-14T14:23:42+09:00 Subject: Re: Metaprograming Jes炭s Gabriel y Gal叩n wrote: > On Thu, Jun 10, 2010 at 11:53 AM, Sateesh Kambhamapati > wrote: >> end >> end >> f=flower.new >> f.rose-------------------->It gives me rose >> but now f.jasmine------------------->It calls method_missing >> but i want it comes to my class "Flower" > > I'm not sure if I understand you correctly, but if you want those > method missing calls, to be called on the Flower class, you can do > this: > > irb(main):001:0> class Flower > irb(main):002:1> def self.jasmine > irb(main):003:2> "jasmine" > irb(main):004:2> end > irb(main):005:1> def method_missing meth, *args, &blk > irb(main):006:2> self.class.send meth, *args, &blk > irb(main):007:2> end > irb(main):008:1> end > => nil > irb(main):016:0> Flower.new.jasmine > => "jasmine" > >> So i Want to know which methods are invoked by my "Flower" object > > I don't understand this question. > > Jesus. Thanks for reply i would like to know which methods are called by class object i.e class Flower def jasmine puts "iam jasmine" end def rose puts "iam rose" end end flowerlist=Flower.new #----->Creating instance for flower flowerlist.jasmine #------->"gives output as "iam jasmine" flowerlist.rose # =======> "gives output as "i am rose" flowerlist.lotus #------->"Shows No Method Error" Question : --> My Question is i would like to know which methods are called by object i.e flowerlist in the class Flower if i already know those methods then suppose if i have not define some method then i will define it dynamically example here is "lotus" i think u understand my question pleasee gave me reply -- Posted via http://www.ruby-forum.com/.