Sha256: 80057506a55bdf341976c7a6774a242df09f35f80e32deff4c0f8fcada5f5813
Contents?: true
Size: 1.68 KB
Versions: 117
Compression:
Stored size: 1.68 KB
Contents
/** * Copyright 2005-2007 Xue Yong Zhi * Distributed under the BSD License */ package com.xruby.runtime.lang; import com.xruby.runtime.builtin.RubyArray; import java.util.*; public class RubyBinding extends RubyBasic { private RubyModule scope_; private RubyValue self_; private RubyBlock block_; private RubyArray variables_ = new RubyArray(); private List<String> names_ = new ArrayList<String>(); public RubyBinding(RubyClass c) { super(c); } public RubyBinding() { super(RubyRuntime.BindingClass); } public boolean hasName(String name) { return names_.indexOf(name) >= 0; } public RubyBinding setScope(RubyModule scope) { scope_ = scope; return this; } public RubyBinding setSelf(RubyValue self) { self_ = self; return this; } public RubyValue getSelf() { return self_; } public RubyBinding setBlock(RubyBlock block) { block_ = block; return this; } public RubyBlock getBlock() { return block_; } public RubyModule getScope() { return scope_; } public void addVariableName(String name) { if (names_.indexOf(name) < 0) { names_.add(name); } } public RubyBinding addVariable(String name, RubyValue value) { int i = names_.indexOf(name); if (i < 0) { names_.add(name); variables_.add(value); } else { variables_.set(i, value); } return this; } public RubyArray getVariables() { return variables_; } public List<String> getVariableNames() { return names_; } protected RubyValue getVariable(String name) { int i = names_.indexOf(name); if (i < 0) { return null; } else { return variables_.get(i); } } }
Version data entries
117 entries across 117 versions & 1 rubygems