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

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

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

Ruby.getInteger介绍

暂无

代码示例

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

public static IRubyObject checkIntegerType(ThreadContext context, IRubyObject obj) {
  if (obj instanceof RubyFixnum) return obj;
  TypeConverterSites sites = sites(context);
  IRubyObject conv = convertToTypeWithCheck(context, obj, context.runtime.getInteger(), sites.to_int_checked);
  return conv instanceof RubyInteger ? conv : context.nil;
}

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

public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) {
  if (obj instanceof RubyFixnum) return obj;
  IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false);
  return conv instanceof RubyInteger ? conv : runtime.getNil();
}

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

public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) {
  if (obj instanceof RubyFixnum) return obj;
  IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false);
  return conv instanceof RubyInteger ? conv : runtime.getNil();
}

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

public static IRubyObject checkIntegerType(ThreadContext context, IRubyObject obj) {
  if (obj instanceof RubyFixnum) return obj;
  TypeConverterSites sites = sites(context);
  IRubyObject conv = convertToTypeWithCheck(context, obj, context.runtime.getInteger(), sites.to_int_checked);
  return conv instanceof RubyInteger ? conv : context.nil;
}

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

public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) {
  if (method.equals("to_int")) return checkIntegerType(runtime.getCurrentContext(), obj);
  if (obj instanceof RubyFixnum) return obj;
  if (method.equals("to_i")) {
    ThreadContext context = runtime.getCurrentContext();
    TypeConverterSites sites = sites(context);
    IRubyObject conv = convertToTypeWithCheck(context, obj, runtime.getInteger(), sites.to_i_checked);
    return conv instanceof RubyInteger ? conv : runtime.getNil();
  }
  IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false);
  return conv instanceof RubyInteger ? conv : runtime.getNil();
}

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

public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) {
  if (method.equals("to_int")) return checkIntegerType(runtime.getCurrentContext(), obj);
  if (obj instanceof RubyFixnum) return obj;
  if (method.equals("to_i")) {
    ThreadContext context = runtime.getCurrentContext();
    TypeConverterSites sites = sites(context);
    IRubyObject conv = convertToTypeWithCheck(context, obj, runtime.getInteger(), sites.to_i_checked);
    return conv instanceof RubyInteger ? conv : runtime.getNil();
  }
  IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false);
  return conv instanceof RubyInteger ? conv : runtime.getNil();
}

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

public static RubyClass createBignumClass(Ruby runtime) {
  RubyClass bignum = runtime.defineClass("Bignum", runtime.getInteger(),
      ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setBignum(bignum);
  bignum.index = ClassIndex.BIGNUM;
  bignum.setReifiedClass(RubyBignum.class);
  bignum.defineAnnotatedMethods(RubyBignum.class);
  return bignum;
}

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

public static RubyClass createBignumClass(Ruby runtime) {
  RubyClass bignum = runtime.getInteger();
  runtime.getObject().setConstant("Bignum", bignum);
  runtime.getObject().deprecateConstant(runtime, "Bignum");
  runtime.setBignum(bignum);
  return bignum;
}

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

public static RubyClass createBignumClass(Ruby runtime) {
  RubyClass bignum = runtime.getInteger();
  runtime.getObject().setConstant("Bignum", bignum);
  runtime.getObject().deprecateConstant(runtime, "Bignum");
  runtime.setBignum(bignum);
  return bignum;
}

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

public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) {
  IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true);
  if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + '#' + convertMethod + " should return Integer");
  return (RubyInteger)val;
}

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

/**
 * Tries to convert this object to a Ruby Integer using the
 * supplied conversion method.
 */
public RubyInteger convertToInteger(String convertMethod) {
  IRubyObject val = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethod, true);
  if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#" + convertMethod + " should return Integer");
  return (RubyInteger)val;
}

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

/**
 * Tries to convert this object to a Ruby Integer using the
 * supplied conversion method.
 */
public RubyInteger convertToInteger(String convertMethod) {
  IRubyObject val = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethod, true);
  if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#" + convertMethod + " should return Integer");
  return (RubyInteger)val;
}

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

public static RubyClass createFixnumClass(Ruby runtime) {
  RubyClass fixnum = runtime.getInteger();
  runtime.getObject().setConstant("Fixnum", fixnum);
  runtime.getObject().deprecateConstant(runtime, "Fixnum");
  runtime.setFixnum(fixnum);
  for (int i = 0; i < runtime.fixnumCache.length; i++) {
    runtime.fixnumCache[i] = new RubyFixnum(fixnum, i - CACHE_OFFSET);
  }
  return fixnum;
}

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

public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) {
  IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true);
  if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + "#" + convertMethod + " should return Integer");
  return (RubyInteger)val;
}

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

public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) {
  IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true);
  if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + "#" + convertMethod + " should return Integer");
  return (RubyInteger)val;
}

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

public static RubyClass createFixnumClass(Ruby runtime) {
  RubyClass fixnum = runtime.getInteger();
  runtime.getObject().setConstant("Fixnum", fixnum);
  runtime.getObject().deprecateConstant(runtime, "Fixnum");
  runtime.setFixnum(fixnum);
  for (int i = 0; i < runtime.fixnumCache.length; i++) {
    runtime.fixnumCache[i] = new RubyFixnum(fixnum, i - CACHE_OFFSET);
  }
  return fixnum;
}

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

public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) {
  IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true);
  if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + '#' + convertMethod + " should return Integer");
  return (RubyInteger)val;
}

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

public IRubyObject aset(IRubyObject index, IRubyObject value) {
   if (! (index instanceof RubyInteger)) {
    throw getRuntime().newTypeError(index, getRuntime().getInteger());
  }
  int intIndex = (int) ((RubyInteger) index).getLongValue();
  if (! (value instanceof JavaObject)) {
    throw getRuntime().newTypeError("not a java object:" + value);
  }
  Object javaObject = ((JavaObject) value).getValue();
  
  ArrayUtils.setWithExceptionHandlingDirect(getRuntime(), javaObject, intIndex, javaObject);
  
  return value;
}

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

public IRubyObject aset(IRubyObject index, IRubyObject value) {
   if (! (index instanceof RubyInteger)) {
    throw getRuntime().newTypeError(index, getRuntime().getInteger());
  }
  int intIndex = (int) ((RubyInteger) index).getLongValue();
  if (! (value instanceof JavaObject)) {
    throw getRuntime().newTypeError("not a java object:" + value);
  }
  Object javaObject = ((JavaObject) value).getValue();
  ArrayUtils.setWithExceptionHandlingDirect(getRuntime(), javaObject, intIndex, javaObject);
  return value;
}

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

public IRubyObject aset(IRubyObject index, IRubyObject value) {
   if (! (index instanceof RubyInteger)) {
    throw getRuntime().newTypeError(index, getRuntime().getInteger());
  }
  int intIndex = (int) ((RubyInteger) index).getLongValue();
  if (! (value instanceof JavaObject)) {
    throw getRuntime().newTypeError("not a java object:" + value);
  }
  Object javaObject = ((JavaObject) value).getValue();
  ArrayUtils.setWithExceptionHandlingDirect(getRuntime(), javaObject, intIndex, javaObject);
  return value;
}

相关文章

微信公众号

最新文章

更多

Ruby类方法