Sha256: 360425994803f112416ab6992b687c0d83f7f35f23083afa0d13f0ad76eef64c

Contents?: true

Size: 640 Bytes

Versions: 3

Compression:

Stored size: 640 Bytes

Contents

require 'facet/binding/eval'
require 'facet/binding/op_store'

class Binding

  # Returns the value of some variable.
  #
  #   a = 2
  #   binding["a"]  #=> 2
  #
  def []( x )
    eval( x.to_s )
  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_op_fetch
      assert_equal( "hello", @bind["x"] )
    end

  end

=end

Version data entries

3 entries across 3 versions & 1 rubygems

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