Minor Change Proposal for Classe 'UnboundMethod'

Discussion in 'Ruby' started by Wolfgang Nádasi-Donner, Jan 19, 2007.

  1. Minor Change Proposal for Classe 'UnboundMethod'
    _______________________________________________________


    I would like to make a small change suggestion on the class 'UnboundMethod'.

    Background:
    ___________

    The proposal is to add one or two additional methods for class 'UnboundMethod',
    which return the contents of 'UnboundMethod#to_s' as an two element Array or the
    parts by two independant methods.

    The method name used by here is only a suggestion, since I need a names for the
    example.
    ___________


    >>>>> Example for Workaround >>>>>

    class UnboundMethod
    def method_name
    md = self.to_s.match(/Method:\s*([^#]+)#([^>]+)>/)
    return md[1], md[2]
    end
    end

    # Now an example

    class Hugo
    def hi
    puts "An instance of Hugo says 'Hi!'"
    end
    end

    my_hugo = Hugo.new
    myhi = my_hugo.method:)hi)
    unbound1 = myhi.unbind
    unbound2 = Hugo.instance_method:)hi)

    p unbound1.method_name # => ["Hugo", "hi"]
    p unbound2.method_name # => ["Hugo", "hi"]
    >>>>> End of Example >>>>>


    ___________


    Wolfgang Nádasi-Donner (WoNáDo)
     
    Wolfgang Nádasi-Donner, Jan 19, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gabriele renzi

    Help with UnboundMethod#bind error

    gabriele renzi, Jun 29, 2003, in forum: Ruby
    Replies:
    3
    Views:
    156
    Yukihiro Matsumoto
    Jun 30, 2003
  2. Robert Klemme
    Replies:
    8
    Views:
    125
    Yukihiro Matsumoto
    Mar 2, 2004
  3. Wolfgang Nádasi-Donner
    Replies:
    3
    Views:
    175
    Wolfgang Nádasi-Donner
    Jan 30, 2007
  4. Wolfgang Nádasi-Donner

    Minor Change Proposal for Class 'Numeric'

    Wolfgang Nádasi-Donner, Jan 22, 2007, in forum: Ruby
    Replies:
    7
    Views:
    128
    Wolfgang Nádasi-Donner
    Jan 23, 2007
  5. Wolfgang Nádasi-Donner
    Replies:
    1
    Views:
    118
    Wolfgang Nádasi-Donner
    May 15, 2007
Loading...

Share This Page