Sha256: 439f91697c6c9f137195f4f307130638d9bf6b33a66749b5904e91292fd7addc

Contents?: true

Size: 1.6 KB

Versions: 118

Compression:

Stored size: 1.6 KB

Contents

/**
 * Copyright 2007 Xue Yong Zhi, Jie Li, Ye Zheng
 * Distributed under the BSD License
 */

package com.xruby.runtime.builtin;

import com.xruby.runtime.lang.RubyAPI;
import com.xruby.runtime.lang.RubyBlock;
import com.xruby.runtime.lang.RubyException;
import com.xruby.runtime.lang.RubyID;
import com.xruby.runtime.lang.RubyRuntime;
import com.xruby.runtime.lang.RubyValue;
//import com.xruby.runtime.lang.annotation.RubyLevelClass;
//import com.xruby.runtime.lang.annotation.RubyLevelMethod;
//import com.xruby.runtime.lang.annotation.UndefMethod;

/*@RubyLevelClass(
		name="Integer", 
		superclass="Numeric",
		undef={
				@UndefMethod(name="new", classMethod=true)
		}
)*/
public abstract class RubyInteger extends RubyNumeric {
	public RubyInteger toRubyInteger() {
		return this;
	}
	
	//@RubyLevelMethod(name="times")
	public RubyValue times(RubyBlock block) {
		RubyValue a = ObjectFactory.FIXNUM0;
        while (RubyAPI.callPublicOneArgMethod(a, this, null, RubyID.ltID).isTrue()) {
            RubyValue v = block.invoke(this, a);
            if (block.breakedOrReturned()) {
                return v;
            }
            a = RubyAPI.callPublicOneArgMethod(a, ObjectFactory.FIXNUM1, null, RubyID.plusID);
        }
        
        return this;
	}
	
	//@RubyLevelMethod(name="chr")
	public RubyValue chr() {
		int i = this.toInt();
		if (i < 0 || i > 0xff) {
			throw new RubyException(RubyRuntime.RangeErrorClass, i + " out of char range");
		}
		
		char charValue = (char)i;
        return ObjectFactory.createString("" + charValue);
	}

	//@RubyLevelMethod(name="ord")
	public RubyValue ord() {
		return this;
	}
	
}

Version data entries

118 entries across 118 versions & 1 rubygems

Version Path
rhodes-3.5.1.12 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.5 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.4.2 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.4 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.3 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.3.beta.4 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.3.beta.3 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.3.beta.2 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.3.beta.1 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.7 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.6 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.5 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.4 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.3 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.2 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.2.beta.1 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.1 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.0 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-3.3.0.beta.3 platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyInteger.java