Sha256: 3fc843b9871d5517332d1e26737d83729eedf5029a980022e46e77fb99bde4df

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

require 'facet/binding/eval'

class Binding

  # Returns the local variables defined in the binding context
  #
  #   require 'facet/binding/local_variables'
  #
  #   a = 2
  #   binding.local_varibales  #=> ["a"]
  #
  def local_variables()
    eval( "local_variables" )
  end
    
  # Returns the value of some variable.
  #
  #   require 'facet/binding/local_variables'
  #
  #   a = 2
  #   binding["a"]  #=> 2
  #
  def []( x )
    eval( x.to_s )
  end
  
  # Set the value of a local variable.
  #
  #   require 'facet/binding/local_variables'
  #
  #   binding["a"] = 4
  #   a  #=> 4
  #
  def []=( l, v )
    eval( "proc {|v| #{l} = v}").call( v )
  end

end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.6.3 lib/facet/binding/local_variables.rb