# this may be the juiciest peice of ruby code i've written in a long time ;-) # # regarding : http://gist.github.com/157782 # regarding : http://drawohara.com/post/151193800/ruby-symbol-to-hash # class Binding def map *vars vars.flatten.compact.inject({}){|h,v| h.update v => eval(v.to_s, self)} end alias_method '>', 'map' end a = 4 b = 2 c = 42 p binding > [:a, :b, :c] p binding > :a p binding > [:a,:c] __END__ cfp:~ > ruby a.rb {:a=>4, :b=>2, :c=>42} {:a=>4} {:a=>4, :c=>42}