public static RubyInteger str2inum(Ruby runtime, RubyString str, int base) { return str2inum(runtime, str, base, false); }
public static RubyInteger str2inum(Ruby runtime, RubyString str, int base) { return str2inum(runtime,str,base,false); }
public static RubyInteger str2inum(Ruby runtime, RubyString str, int base) { return str2inum(runtime, str, base, false); }
public static RubyInteger str2inum(Ruby runtime, RubyString str, int base) { return str2inum(runtime,str,base,false); }
public IRubyObject create(Ruby runtime, org.yecht.Node n, Data.Str ds) { n.strBlowAwayCommas(); return RubyNumeric.str2inum(runtime, RubyString.newStringShared(runtime, ds.ptr.buffer, ds.ptr.start, ds.len), 8, true); } });
public IRubyObject create(Ruby runtime, org.yecht.Node n, Data.Str ds) { n.strBlowAwayCommas(); return RubyNumeric.str2inum(runtime, RubyString.newStringShared(runtime, ds.ptr.buffer, ds.ptr.start, ds.len), 16, true); } });
@JRubyMethod(name = "Integer", module = true, visibility = PRIVATE, compat = RUBY1_9) public static IRubyObject new_integer19(ThreadContext context, IRubyObject recv, IRubyObject object, IRubyObject base) { int bs = RubyNumeric.num2int(base); if(object instanceof RubyString) { return RubyNumeric.str2inum(context.runtime,(RubyString)object,bs,true); } else { IRubyObject tmp = object.checkStringType(); if(!tmp.isNil()) { return RubyNumeric.str2inum(context.runtime,(RubyString)tmp,bs,true); } } throw context.runtime.newArgumentError("base specified for non string value"); }
@JRubyMethod(name = "Integer", module = true, visibility = PRIVATE, compat = RUBY1_9) public static IRubyObject new_integer19(ThreadContext context, IRubyObject recv, IRubyObject object, IRubyObject base) { int bs = RubyNumeric.num2int(base); if(object instanceof RubyString) { return RubyNumeric.str2inum(context.runtime,(RubyString)object,bs,true); } else { IRubyObject tmp = object.checkStringType(); if(!tmp.isNil()) { return RubyNumeric.str2inum(context.runtime,(RubyString)tmp,bs,true); } } throw context.runtime.newArgumentError("base specified for non string value"); }
if(type_id.startsWith("int")) { n.strBlowAwayCommas(); obj = RubyNumeric.str2inum(runtime, RubyString.newStringShared(runtime, ds.ptr.buffer, ds.ptr.start, ds.len), 10, true); } else if(type_id.startsWith("float")) { n.strBlowAwayCommas();
@JRubyMethod(name = "Integer", required = 1, module = true, visibility = PRIVATE, compat = RUBY1_8) public static IRubyObject new_integer(ThreadContext context, IRubyObject recv, IRubyObject object) { if (object instanceof RubyFloat) { double val = ((RubyFloat)object).getDoubleValue(); if (val >= (double) RubyFixnum.MAX || val < (double) RubyFixnum.MIN) { return RubyNumeric.dbl2num(context.runtime,((RubyFloat)object).getDoubleValue()); } } else if (object instanceof RubyFixnum || object instanceof RubyBignum) { return object; } else if (object instanceof RubyString) { return RubyNumeric.str2inum(context.runtime,(RubyString)object,0,true); } IRubyObject tmp = TypeConverter.convertToType(object, context.runtime.getInteger(), "to_int", false); if (tmp.isNil()) return object.convertToInteger("to_i"); return tmp; }
@JRubyMethod(name = "Integer", required = 1, module = true, visibility = PRIVATE, compat = RUBY1_8) public static IRubyObject new_integer(ThreadContext context, IRubyObject recv, IRubyObject object) { if (object instanceof RubyFloat) { double val = ((RubyFloat)object).getDoubleValue(); if (val >= (double) RubyFixnum.MAX || val < (double) RubyFixnum.MIN) { return RubyNumeric.dbl2num(context.runtime,((RubyFloat)object).getDoubleValue()); } } else if (object instanceof RubyFixnum || object instanceof RubyBignum) { return object; } else if (object instanceof RubyString) { return RubyNumeric.str2inum(context.runtime,(RubyString)object,0,true); } IRubyObject tmp = TypeConverter.convertToType(object, context.runtime.getInteger(), "to_int", false); if (tmp.isNil()) return object.convertToInteger("to_i"); return tmp; }
@JRubyMethod(name = "Integer", module = true, visibility = PRIVATE, compat = RUBY1_9) public static IRubyObject new_integer19(ThreadContext context, IRubyObject recv, IRubyObject object) { if (object instanceof RubyFloat) { double val = ((RubyFloat)object).getDoubleValue(); if (val > (double) RubyFixnum.MAX && val < (double) RubyFixnum.MIN) { return RubyNumeric.dbl2num(context.runtime,((RubyFloat)object).getDoubleValue()); } } else if (object instanceof RubyFixnum || object instanceof RubyBignum) { return object; } else if (object instanceof RubyString) { return RubyNumeric.str2inum(context.runtime,(RubyString)object,0,true); } else if(object instanceof RubyNil) { throw context.runtime.newTypeError("can't convert nil into Integer"); } IRubyObject tmp = TypeConverter.convertToType(object, context.runtime.getInteger(), "to_int", false); if (tmp.isNil()) return object.convertToInteger("to_i"); return tmp; }
@JRubyMethod(name = "Integer", module = true, visibility = PRIVATE, compat = RUBY1_9) public static IRubyObject new_integer19(ThreadContext context, IRubyObject recv, IRubyObject object) { if (object instanceof RubyFloat) { double val = ((RubyFloat)object).getDoubleValue(); if (val > (double) RubyFixnum.MAX && val < (double) RubyFixnum.MIN) { return RubyNumeric.dbl2num(context.runtime,((RubyFloat)object).getDoubleValue()); } } else if (object instanceof RubyFixnum || object instanceof RubyBignum) { return object; } else if (object instanceof RubyString) { return RubyNumeric.str2inum(context.runtime,(RubyString)object,0,true); } else if(object instanceof RubyNil) { throw context.runtime.newTypeError("can't convert nil into Integer"); } IRubyObject tmp = TypeConverter.convertToType(object, context.runtime.getInteger(), "to_int", false); if (tmp.isNil()) return object.convertToInteger("to_i"); return tmp; }
return val; case STRING: return RubyNumeric.str2inum(context.runtime, (RubyString) val, base, true); case NIL: if (base != 0) raiseIntegerBaseError(context); default: // MRI checks String sub-classes if (val instanceof RubyString) { return RubyNumeric.str2inum(context.runtime, (RubyString) val, base, true);
return val; case STRING: return RubyNumeric.str2inum(context.runtime, (RubyString) val, base, true); case NIL: if (base != 0) raiseIntegerBaseError(context); default: // MRI checks String sub-classes if (val instanceof RubyString) { return RubyNumeric.str2inum(context.runtime, (RubyString) val, base, true);
args[0] = RubyNumeric.str2inum(runtime, (RubyString) args[0], 10, false);
args[0] = RubyNumeric.str2inum(runtime, (RubyString) args[0], 10, false);
} else if(!target_class.isNil()) { if(subclass == runtime.getBignum()) { obj = RubyNumeric.str2inum(runtime, val.convertToString(), 10); } else { obj = ((RubyClass)subclass).allocate();