Sha256: f894c09918b40b3306e251415c5fa68f4cad352ce18a6e6cf2494ef964794abb

Contents?: true

Size: 1.51 KB

Versions: 135

Compression:

Stored size: 1.51 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);
	}
}

Version data entries

135 entries across 135 versions & 2 rubygems

Version Path
rhodes-2.0.0.beta7 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-2.0.0.beta6 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-2.0.0.beta4 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-2.0.0.beta3 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.5.5 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-2.0.0.beta2 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-2.0.0.beta1 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.5.4 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.5.3 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.5.2 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.5.1 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.5.0 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.4.2 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.4.1 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java
rhodes-1.4.0 platform/shared/xruby/src/com/xruby/runtime/builtin/RubyInteger.java