Sha256: c9a2324bf33212529b9b4add7215a616ea1c35a4fe61ad994523bb1096f520d3

Contents?: true

Size: 447 Bytes

Versions: 3

Compression:

Stored size: 447 Bytes

Contents

module Kernel
  # Retreive the current running method.
  # There is a lot of debate on what to call this.
  # #method_name differs from #called only by the fact
  # that it returns a string, rather then a symbol.
  #
  #   require 'facet/main/method_name'
  #
  #   def tester; p method_name; end
  #   tester  #=> "tester"
  #
  def method_name
    name = /\`([^\']+)\'/.match(caller(1).first)[1]
    return name
  end
  private :method_name
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/kernel/method_name.rb
facets-0.7.1 lib/facet/kernel/method_name.rb
facets-0.7.2 lib/facet/kernel/method_name.rb