Sha256: c6de15e43c99cd54066250b80084da2eaf6c7a93f9b32b3ff3a28234eaca6d22

Contents?: true

Size: 1.16 KB

Versions: 254

Compression:

Stored size: 1.16 KB

Contents

package com.xruby.runtime.lang;

import com.xruby.runtime.builtin.RubyArray;

public abstract class RubyOneOrTwoArgMethod extends RubyMethod {
	public RubyOneOrTwoArgMethod() {
		super(-1, false, 0);
	}
	
	public RubyValue invoke(RubyValue receiver, RubyBlock block) {
		throw new RubyException(RubyRuntime.ArgumentErrorClass, "in `" + this.getID() + "': wrong number of arguments (0 for 1)");
	}

	protected abstract RubyValue run(RubyValue receiver, RubyValue arg, RubyBlock block);
	
	protected abstract RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block);
	
	protected RubyValue run(RubyValue receiver, RubyArray args, RubyBlock block) {
		int size = args.size();
		switch (size) {
		case 0:
			// should not reach here
			throw new RubyException(RubyRuntime.ArgumentErrorClass, "in `" + this.getID() + "': wrong number of arguments (0 for 1)");
		case 1:
			return this.run(receiver, args.get(0), block);
		case 2:
			return this.run(receiver, args.get(0), args.get(1), block);
		}
		
		// should not reach here
		throw new RubyException(RubyRuntime.ArgumentErrorClass, "in `" + this.getID() + "': wrong number of arguments (" + size + " for 2)");
	}
}

Version data entries

254 entries across 136 versions & 2 rubygems

Version Path
rhodes-7.6.0 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-7.5.1 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-7.4.1 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-7.1.17 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-6.2.0 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-6.0.11 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.18 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.17 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.15 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.0.22 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.2 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.0.7 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.0.3 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-5.5.0 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
tauplatform-1.0.3 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
tauplatform-1.0.2 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
tauplatform-1.0.1 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-3.5.1.12 platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-3.5.1.12 platform/shared/xruby/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java
rhodes-3.3.5 platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyOneOrTwoArgMethod.java