Sha256: 5b058f700e30cb197a2a6a600284289cd78aacae97e6e5b41f212fb93a389132

Contents?: true

Size: 427 Bytes

Versions: 3

Compression:

Stored size: 427 Bytes

Contents

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 unless method_defined?(:name) # 1.8.7+

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.8.1 lib/core/facets/unboundmethod/name.rb
facets-2.8.0 lib/core/facets/unboundmethod/name.rb
facets-2.7.0 lib/core/facets/unboundmethod/name.rb