Sha256: 583b99c756e754076541d6ab1ac56c627d834e6f635c9bf6aec6cc3db6c3e79f

Contents?: true

Size: 691 Bytes

Versions: 3

Compression:

Stored size: 691 Bytes

Contents

require 'facet/binding/eval'

class Binding

  # Returns the local variables defined in the binding context
  #
  #   a = 2
  #   binding.local_variables  #=> ["a"]
  #
  def local_variables()
    eval( "local_variables" )
  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_local_variables
      assert_equal( ["a","b","x"], @bind.local_variables )
    end

  end

=end

Version data entries

3 entries across 3 versions & 1 rubygems

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