public RubyFloat(Ruby runtime, double value) { super(runtime.getFloat()); this.value = value; this.flags |= FROZEN_F; }
public RubyFloat(Ruby runtime, double value) { super(runtime.getFloat()); this.value = value; this.flags |= FROZEN_F; }
public static RubyFloat convertToFloat(IRubyObject self) { return (RubyFloat) TypeConverter.convertToType(self, getRuntime(self).getFloat(), "to_f"); }
public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj) { if (obj instanceof RubyFloat) return obj; if (!(obj instanceof RubyNumeric)) return runtime.getNil(); return TypeConverter.convertToTypeWithCheck(obj, runtime.getFloat(), "to_f"); }
/** * Tries to convert this object to a Ruby Float using the "to_f" * method. */ public RubyFloat convertToFloat() { return (RubyFloat) TypeConverter.convertToType(this, getRuntime().getFloat(), "to_f"); }
public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj) { if (obj instanceof RubyFloat) return obj; ThreadContext context = runtime.getCurrentContext(); TypeConverterSites sites = sites(context); return TypeConverter.convertToTypeWithCheck(context, obj, runtime.getFloat(), sites.to_f_checked); }
public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj) { if (obj instanceof RubyFloat) return obj; ThreadContext context = runtime.getCurrentContext(); TypeConverterSites sites = sites(context); return TypeConverter.convertToTypeWithCheck(context, obj, runtime.getFloat(), sites.to_f_checked); }
@JRubyMethod public static IRubyObject prec_f(ThreadContext context, IRubyObject receiver, Block block) { return receiver.getRuntime().getFloat().callMethod(context, "induced_from", receiver); } }
@JRubyMethod public static IRubyObject prec_f(ThreadContext context, IRubyObject receiver, Block block) { return receiver.getRuntime().getFloat().callMethod(context, "induced_from", receiver); } }
private static RubyFloat needFloat(IRubyObject x) { if (x instanceof RubyFloat) { return (RubyFloat)x; } if (!x.getRuntime().getNumeric().isInstance(x)) { TypeConverter.handleUncoercibleObject(true, x, x.getRuntime().getFloat()); } return (RubyFloat) TypeConverter.convertToType19(x, x.getRuntime().getFloat(), "to_f", true); }
public static RubyFloat toFloat(Ruby runtime, IRubyObject obj) { if (obj instanceof RubyNumeric) { return ((RubyNumeric) obj).convertToFloat(); } if (obj instanceof RubyString || obj.isNil()) { throw runtime.newTypeError(obj, "Float"); } return (RubyFloat) TypeConverter.convertToType(obj, runtime.getFloat(), "to_f", true); }
/** * Tries to convert this object to a Ruby Float using the "to_f" method. * @return float representation of this */ @Override public RubyFloat convertToFloat() { Ruby runtime = getRuntime(); ThreadContext context = runtime.getCurrentContext(); BasicObjectSites sites = sites(context); return (RubyFloat) TypeConverter.convertToType(context, this, runtime.getFloat(), sites.to_f_checked); }
public static RubyFloat toFloat(Ruby runtime, IRubyObject obj) { if (obj instanceof RubyNumeric) { return ((RubyNumeric) obj).convertToFloat(); } if (obj instanceof RubyString || obj.isNil()) { throw runtime.newTypeError(obj, "Float"); } return (RubyFloat) TypeConverter.convertToType(obj, runtime.getFloat(), "to_f", true); }
/** * Tries to convert this object to a Ruby Float using the "to_f" method. * @return float representation of this */ @Override public RubyFloat convertToFloat() { Ruby runtime = getRuntime(); ThreadContext context = runtime.getCurrentContext(); BasicObjectSites sites = sites(context); return (RubyFloat) TypeConverter.convertToType(context, this, runtime.getFloat(), sites.to_f_checked); }
public static RubyNumeric toFloat(Ruby runtime, IRubyObject obj) { RubyClass floatClass = runtime.getFloat(); if (floatClass.isInstance(obj)) return (RubyNumeric) obj; if (!runtime.getNumeric().isInstance(obj)) throw runtime.newTypeError(obj, "Float"); return (RubyNumeric) convertToType19(obj, floatClass, "to_f", true); } /**
public static RubyNumeric toFloat(Ruby runtime, IRubyObject obj) { RubyClass floatClass = runtime.getFloat(); if (floatClass.isInstance(obj)) return (RubyNumeric) obj; if (!runtime.getNumeric().isInstance(obj)) throw runtime.newTypeError(obj, "Float"); return (RubyNumeric) convertToType19(obj, floatClass, "to_f", true); } /**
protected void invalidateCoreClasses() { if (!getRuntime().isBootingCore()) { if (this == getRuntime().getFixnum()) { getRuntime().reopenFixnum(); } else if (this == getRuntime().getFloat()) { getRuntime().reopenFloat(); } } }
protected void invalidateCoreClasses() { if (!getRuntime().isBootingCore()) { if (this == getRuntime().getFixnum()) { getRuntime().reopenFixnum(); } else if (this == getRuntime().getFloat()) { getRuntime().reopenFloat(); } } }
protected void invalidateCoreClasses() { if (!getRuntime().isBooting()) { if (this == getRuntime().getFixnum()) { getRuntime().reopenFixnum(); } else if (this == getRuntime().getFloat()) { getRuntime().reopenFloat(); } } }
@JRubyMethod(name = "initialize", visibility = PRIVATE, compat = RUBY2_0) public IRubyObject initialize20(ThreadContext context, IRubyObject object, Block block) { Ruby runtime = context.runtime; RubySymbol each = runtime.newSymbol("each"); // check for size if ((object.isNil() || runtime.getProc().isInstance(object)) || runtime.getFloat().isInstance(object) && ((RubyFloat)object).getDoubleValue() == Float.POSITIVE_INFINITY) { // object is nil, a proc, or infinity; use it for size IRubyObject gen = context.runtime.getModule("JRuby").getClass("Generator").callMethod(context, "new", new IRubyObject[0], block); return initialize20(gen, each, NULL_ARRAY, object); } return initialize(object, each, NULL_ARRAY); }