Sha256: 7dbd475e402156625e5169a12956f89e7a5f6f10e1c7640cddbec5e108952567

Contents?: true

Size: 626 Bytes

Versions: 3

Compression:

Stored size: 626 Bytes

Contents

require 'facet/binding/eval'

class Binding

  # Returns the call stack, same format as Kernel#caller()
  def caller( skip = 0 )
    eval( "caller( #{skip} )" )
  end

end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCBinding < Test::Unit::TestCase

    def setup
      a = 1
      b = 2
      x = "hello"
      # the line number must be updated if it moves
      @bind = binding; @this_line_no = 25
    end

    def test_caller
      # how to test?
      assert_nothing_raised{ @bind.caller }
    end

  end

=end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-1.0.0 lib/facet/binding/caller.rb
facets-1.0.3 packages/core/lib/facet/binding/caller.rb
facets-1.1.0 lib/facet/binding/caller.rb