Sha256: d39e50bbcf8dc74d84c297d324e17460d118fc239442fed1d6d1fcb4768b9bf6

Contents?: true

Size: 457 Bytes

Versions: 3

Compression:

Stored size: 457 Bytes

Contents

if RUBY_VERSION < '1.9'

  class UnboundMethod

    # Return the name of the method.
    #
    # Be aware that in ruby 1.9 UnboundMethod#name is defined already,
    # but it returns a Symbol not a String.
    #
    #   class X
    #     def foo; end
    #   end
    #
    #   meth = X.instance_method(:foo)
    #
    #   meth.name  #=> "foo"
    #
    # CREDIT: Trans

    def name
      i = to_s.rindex('#')
      to_s.slice(i+1...-1)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.6.0 lib/core/facets/unboundmethod/name.rb
facets-2.5.1 lib/core/facets/unboundmethod/name.rb
facets-2.5.2 lib/core/facets/unboundmethod/name.rb