org.jruby.Ruby.getNumeric()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.jruby.Ruby.getNumeric方法的一些代码示例,展示了Ruby.getNumeric的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getNumeric方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getNumeric

Ruby.getNumeric介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-core

public static RubyNumeric newNumeric(Ruby runtime) {
  return new RubyNumeric(runtime, runtime.getNumeric());
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyNumeric newNumeric(Ruby runtime) {
  return new RubyNumeric(runtime, runtime.getNumeric());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyNumeric newNumeric(Ruby runtime) {
  return new RubyNumeric(runtime, runtime.getNumeric());
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static RubyNumeric newNumeric(Ruby runtime) {
  return new RubyNumeric(runtime, runtime.getNumeric());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

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);
}
/**

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

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);
}
/**

代码示例来源:origin: org.jruby/jruby-complete

public static RubyClass createIntegerClass(Ruby runtime) {
  RubyClass integer = runtime.defineClass("Integer", runtime.getNumeric(),
      ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setInteger(integer);
  integer.setClassIndex(ClassIndex.INTEGER);
  integer.setReifiedClass(RubyInteger.class);
  integer.kindOf = new RubyModule.JavaClassKindOf(RubyInteger.class);
  integer.getSingletonClass().undefineMethod("new");
  integer.defineAnnotatedMethods(RubyInteger.class);
  return integer;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

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);
}

代码示例来源:origin: org.jruby/jruby-core

public static RubyClass createIntegerClass(Ruby runtime) {
  RubyClass integer = runtime.defineClass("Integer", runtime.getNumeric(),
      ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setInteger(integer);
  integer.setClassIndex(ClassIndex.INTEGER);
  integer.setReifiedClass(RubyInteger.class);
  integer.kindOf = new RubyModule.JavaClassKindOf(RubyInteger.class);
  integer.getSingletonClass().undefineMethod("new");
  integer.defineAnnotatedMethods(RubyInteger.class);
  return integer;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

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);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyClass createIntegerClass(Ruby runtime) {
  RubyClass integer = runtime.defineClass("Integer", runtime.getNumeric(),
      ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setInteger(integer);
  integer.index = ClassIndex.INTEGER;
  integer.setReifiedClass(RubyInteger.class);
  
  integer.kindOf = new RubyModule.JavaClassKindOf(RubyInteger.class);
  integer.getSingletonClass().undefineMethod("new");
  if (!runtime.is1_9()) {
    integer.includeModule(runtime.getPrecision());
  }
  integer.defineAnnotatedMethods(RubyInteger.class);
  
  return integer;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyClass createRationalClass(Ruby runtime) {
  RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR);
  runtime.setRational(rationalc);
  rationalc.index = ClassIndex.RATIONAL;
  rationalc.setReifiedClass(RubyRational.class);
  
  rationalc.kindOf = new RubyModule.JavaClassKindOf(RubyRational.class);
  rationalc.setMarshal(RATIONAL_MARSHAL);
  rationalc.defineAnnotatedMethods(RubyRational.class);
  rationalc.getSingletonClass().undefineMethod("allocate");
  rationalc.getSingletonClass().undefineMethod("new");
  return rationalc;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static RubyClass createRationalClass(Ruby runtime) {
  RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR);
  runtime.setRational(rationalc);
  rationalc.index = ClassIndex.RATIONAL;
  rationalc.setReifiedClass(RubyRational.class);
  
  rationalc.kindOf = new RubyModule.JavaClassKindOf(RubyRational.class);
  rationalc.setMarshal(RATIONAL_MARSHAL);
  rationalc.defineAnnotatedMethods(RubyRational.class);
  rationalc.getSingletonClass().undefineMethod("allocate");
  rationalc.getSingletonClass().undefineMethod("new");
  return rationalc;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyClass createRationalClass(Ruby runtime) {
  RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR);
  runtime.setRational(rationalc);
  rationalc.setClassIndex(ClassIndex.RATIONAL);
  rationalc.setReifiedClass(RubyRational.class);
  
  rationalc.kindOf = new RubyModule.JavaClassKindOf(RubyRational.class);
  rationalc.setMarshal(RATIONAL_MARSHAL);
  rationalc.defineAnnotatedMethods(RubyRational.class);
  rationalc.getSingletonClass().undefineMethod("allocate");
  rationalc.getSingletonClass().undefineMethod("new");
  return rationalc;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static RubyClass createIntegerClass(Ruby runtime) {
  RubyClass integer = runtime.defineClass("Integer", runtime.getNumeric(),
      ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setInteger(integer);
  integer.index = ClassIndex.INTEGER;
  integer.setReifiedClass(RubyInteger.class);
  
  integer.kindOf = new RubyModule.JavaClassKindOf(RubyInteger.class);
  integer.getSingletonClass().undefineMethod("new");
  if (!runtime.is1_9()) {
    integer.includeModule(runtime.getPrecision());
  }
  integer.defineAnnotatedMethods(RubyInteger.class);
  
  return integer;
}

代码示例来源:origin: org.jruby/jruby-core

public static RubyClass createRationalClass(Ruby runtime) {
  RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR);
  runtime.setRational(rationalc);
  rationalc.setClassIndex(ClassIndex.RATIONAL);
  rationalc.setReifiedClass(RubyRational.class);
  
  rationalc.kindOf = new RubyModule.JavaClassKindOf(RubyRational.class);
  rationalc.setMarshal(RATIONAL_MARSHAL);
  rationalc.defineAnnotatedMethods(RubyRational.class);
  rationalc.getSingletonClass().undefineMethod("allocate");
  rationalc.getSingletonClass().undefineMethod("new");
  return rationalc;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyClass createComplexClass(Ruby runtime) {
  RubyClass complexc = runtime.defineClass("Complex", runtime.getNumeric(), COMPLEX_ALLOCATOR);
  runtime.setComplex(complexc);
  complexc.index = ClassIndex.COMPLEX;
  complexc.setReifiedClass(RubyComplex.class);
  
  complexc.kindOf = new RubyModule.JavaClassKindOf(RubyComplex.class);
  complexc.defineAnnotatedMethods(RubyComplex.class);
  complexc.getSingletonClass().undefineMethod("allocate");
  complexc.getSingletonClass().undefineMethod("new");
  String[]undefined = {"<", "<=", "<=>", ">", ">=", "between?", "divmod",
             "floor", "ceil", "modulo", "round", "step", "truncate"};
  for (String undef : undefined) {
    complexc.undefineMethod(undef);
  }
  complexc.defineConstant("I", RubyComplex.newComplexConvert(runtime.getCurrentContext(), RubyFixnum.zero(runtime), RubyFixnum.one(runtime)));
  return complexc;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyClass createBigDecimal(Ruby runtime) {
  RubyClass bigDecimal = runtime.defineClass("BigDecimal", runtime.getNumeric(), BIGDECIMAL_ALLOCATOR);
  runtime.getKernel().defineAnnotatedMethods(BigDecimalKernelMethods.class);
  bigDecimal.setInternalModuleVariable("vpPrecLimit", RubyFixnum.zero(runtime));
  bigDecimal.setInternalModuleVariable("vpExceptionMode", RubyFixnum.zero(runtime));
  bigDecimal.setInternalModuleVariable("vpRoundingMode", runtime.newFixnum(ROUND_HALF_UP));
  
  bigDecimal.defineAnnotatedMethods(RubyBigDecimal.class);
  bigDecimal.defineAnnotatedConstants(RubyBigDecimal.class);
  if (runtime.is1_9()) {
    RubyModule bigMath = runtime.defineModule("BigMath");
    // TODO: BigMath.exp and BigMath.pow in native code
    bigDecimal.defineConstant("NAN", newNaN(runtime));
    bigDecimal.defineConstant("INFINITY", newInfinity(runtime, 1));
  }
  return bigDecimal;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyClass createBigDecimal(Ruby runtime) {
  RubyClass bigDecimal = runtime.defineClass("BigDecimal", runtime.getNumeric(), ALLOCATOR);
  bigDecimal.setConstant("VERSION", RubyString.newStringShared(runtime, VERSION));
  runtime.getKernel().defineAnnotatedMethods(BigDecimalKernelMethods.class);
  bigDecimal.setInternalModuleVariable("vpPrecLimit", RubyFixnum.zero(runtime));
  bigDecimal.setInternalModuleVariable("vpExceptionMode", RubyFixnum.zero(runtime));
  bigDecimal.setInternalModuleVariable("vpRoundingMode", runtime.newFixnum(ROUND_HALF_UP));
  bigDecimal.defineAnnotatedMethods(RubyBigDecimal.class);
  bigDecimal.defineAnnotatedConstants(RubyBigDecimal.class);
  //RubyModule bigMath = runtime.defineModule("BigMath");
  // NOTE: BigMath.exp and BigMath.pow should be implemented as native
  // for now @see jruby/bigdecimal.rb
  bigDecimal.defineConstant("NAN", newNaN(runtime));
  bigDecimal.defineConstant("INFINITY", newInfinity(runtime, 1));
  
  bigDecimal.setReifiedClass(RubyBigDecimal.class);
  return bigDecimal;
}

代码示例来源:origin: org.jruby/jruby-core

public static RubyClass createBigDecimal(Ruby runtime) {
  RubyClass bigDecimal = runtime.defineClass("BigDecimal", runtime.getNumeric(), ALLOCATOR);
  bigDecimal.setConstant("VERSION", RubyString.newStringShared(runtime, VERSION));
  runtime.getKernel().defineAnnotatedMethods(BigDecimalKernelMethods.class);
  bigDecimal.setInternalModuleVariable("vpPrecLimit", RubyFixnum.zero(runtime));
  bigDecimal.setInternalModuleVariable("vpExceptionMode", RubyFixnum.zero(runtime));
  bigDecimal.setInternalModuleVariable("vpRoundingMode", runtime.newFixnum(ROUND_HALF_UP));
  bigDecimal.defineAnnotatedMethods(RubyBigDecimal.class);
  bigDecimal.defineAnnotatedConstants(RubyBigDecimal.class);
  //RubyModule bigMath = runtime.defineModule("BigMath");
  // NOTE: BigMath.exp and BigMath.pow should be implemented as native
  // for now @see jruby/bigdecimal.rb
  bigDecimal.defineConstant("NAN", newNaN(runtime));
  bigDecimal.defineConstant("INFINITY", newInfinity(runtime, 1));
  
  bigDecimal.setReifiedClass(RubyBigDecimal.class);
  return bigDecimal;
}

相关文章

Ruby类方法