1 34 package org.jruby; 35 36 import org.jruby.runtime.Block; 37 import org.jruby.runtime.Frame; 38 import org.jruby.runtime.ThreadContext; 39 40 43 public class RubyBinding extends RubyObject { 44 private Block block = null; 45 private RubyModule wrapper = null; 46 47 public RubyBinding(Ruby runtime, RubyClass rubyClass, Block block, RubyModule wrapper) { 48 super(runtime, rubyClass); 49 50 this.block = block; 51 this.wrapper = wrapper; 52 } 53 54 public Block getBlock() { 55 return block; 56 } 57 58 public RubyModule getWrapper() { 59 return wrapper; 60 } 61 62 64 public static RubyBinding newBinding(Ruby runtime, Block block) { 65 return new RubyBinding(runtime, runtime.getClass("Binding"), block, block.getKlass()); 66 } 67 68 public static RubyBinding newBinding(Ruby runtime) { 69 ThreadContext context = runtime.getCurrentContext(); 70 71 RubyModule wrapper = context.getWrapper(); 73 Frame frame = context.getCurrentFrame(); 74 75 Block bindingBlock = Block.createBinding(wrapper, frame, context.getCurrentScope()); 76 return new RubyBinding(runtime, runtime.getClass("Binding"), bindingBlock, context.getBindingRubyClass()); 77 } 78 } 79 | Popular Tags |