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

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

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

Ruby.newArray介绍

暂无

代码示例

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod
public IRubyObject initialize(ThreadContext context) {
  Ruby runtime = context.runtime;
  this.pendingList = runtime.newArray();
  return this;
}

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod
public IRubyObject each(ThreadContext context, Block block) {
  Ruby runtime = context.runtime;
  for (Descriptors.EnumValueDescriptor enumValueDescriptor : descriptor.getValues()) {
    block.yield(context, runtime.newArray(runtime.newSymbol(enumValueDescriptor.getName()),
        runtime.newFixnum(enumValueDescriptor.getNumber())));
  }
  return runtime.getNil();
}

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod(name = "finalize_to_pool")
public IRubyObject finalizeToPool(ThreadContext context, IRubyObject rbPool) {
  RubyDescriptorPool pool = (RubyDescriptorPool) rbPool;
  for (int i = 0; i < this.pendingList.size(); i++) {
    IRubyObject defRb = this.pendingList.entry(i);
    if (defRb instanceof RubyDescriptor) {
      pool.addToSymtab(context, (RubyDescriptor) defRb);
    } else {
      pool.addToSymtab(context, (RubyEnumDescriptor) defRb);
    }
  }
  this.pendingList = context.runtime.newArray();
  return context.runtime.getNil();
}

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod(required = 1, optional = 2)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
  Ruby runtime = context.runtime;
  this.storage = runtime.newArray();
  IRubyObject ary = null;
  if (!(args[0] instanceof RubySymbol)) {

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

/** nucomp_rect
 * 
 */
@JRubyMethod(name = {"rectangular", "rect"})
@Override
public IRubyObject rect(ThreadContext context) {
  return context.runtime.newArray(real, image);
}

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

/** nucomp_rect
 * 
 */
@JRubyMethod(name = {"rectangular", "rect"})
@Override
public IRubyObject rect(ThreadContext context) {
  return context.runtime.newArray(real, image);
}

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

@JRubyMethod(name = "rassoc")
public IRubyObject rassoc(final ThreadContext context, final IRubyObject obj) {
  try {
    visitAll(context, FoundPairIfEqualValueVisitor, obj);
    return context.nil;
  } catch (FoundPair found) {
    return context.runtime.newArray(found.key, found.value);
  }
}

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

@JRubyMethod(name = {"to_a", "values"})
@Override
public RubyArray to_a() {
  return getRuntime().newArray(values);
}

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

@JRubyMethod(name = "assoc")
public IRubyObject assoc(final ThreadContext context, final IRubyObject obj) {
  try {
    visitAll(context, FoundPairIfEqualKeyVisitor, obj);
    return context.nil;
  } catch (FoundPair found) {
    return context.runtime.newArray(found.key, found.value);
  }
}

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

@JRubyMethod(name = "assoc")
public IRubyObject assoc(final ThreadContext context, final IRubyObject obj) {
  try {
    visitAll(context, FoundPairIfEqualKeyVisitor, obj);
    return context.nil;
  } catch (FoundPair found) {
    return context.runtime.newArray(found.key, found.value);
  }
}

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

/** rb_mod_ancestors
 *
 */
@JRubyMethod(name = "ancestors")
public RubyArray ancestors(ThreadContext context) {
  return context.runtime.newArray(getAncestorList());
}

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

@JRubyMethod(name = {"to_a", "values"})
@Override
public RubyArray to_a() {
  return getRuntime().newArray(values);
}

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

/** nucomp_marshal_dump
 * 
 */
@JRubyMethod(name = "marshal_dump")
public IRubyObject marshal_dump(ThreadContext context) {
  RubyArray dump = context.runtime.newArray(real, image);
  if (hasVariables()) dump.syncVariables(this);
  return dump;
}

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

@JRubyMethod(name = { "to_a", "entries" }) // @override Enumerable#to_a
public static IRubyObject to_a(final ThreadContext context, final IRubyObject self, final Block block) {
  final Ruby runtime = context.runtime;
  final RubyArray ary = runtime.newArray();
  java.lang.Iterable iterable = unwrapIfJavaObject(self);
  java.util.Iterator iterator = iterable.iterator();
  while ( iterator.hasNext() ) {
    final Object value = iterator.next();
    ary.append( convertJavaToUsableRubyObject(runtime, value) );
  }
  return ary;
}

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

/** nucomp_polar 
 * 
 */
@JRubyMethod(name = "polar")
@Override
public IRubyObject polar(ThreadContext context) {
  return context.runtime.newArray(f_abs(context, this), f_arg(context, this));
}

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

@JRubyMethod
public IRubyObject addr(ThreadContext context) {
  final Ruby runtime = context.runtime;
  return runtime.newArray( runtime.newString("AF_UNIX"),  RubyString.newEmptyString(runtime) );
}

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

/** nurat_marshal_dump
 * 
 */
@JRubyMethod(name = "marshal_dump")
public IRubyObject marshal_dump(ThreadContext context) {
  RubyArray dump = context.runtime.newArray(num, den);
  if (hasVariables()) dump.syncVariables(this);
  return dump;
}

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

/** flo_coerce
 *
 */
@JRubyMethod(name = "coerce", required = 1)
@Override
public IRubyObject coerce(IRubyObject other) {
  final Ruby runtime = getRuntime();
  return runtime.newArray(RubyKernel.new_float(runtime, other), this);
}

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

/** num_coerce
 *
 */
@JRubyMethod(name = "coerce")
public IRubyObject coerce(IRubyObject other) {
  final Ruby runtime = getRuntime();
  if (getMetaClass() == other.getMetaClass()) return runtime.newArray(other, this);
  IRubyObject cdr = RubyKernel.new_float(runtime, this);
  IRubyObject car = RubyKernel.new_float(runtime, other);
  return runtime.newArray(car, cdr);
}

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

@JRubyMethod(name = "waitpid2", rest = true, module = true, visibility = PRIVATE)
public static IRubyObject waitpid2(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
  IRubyObject pid = waitpid(context, recv, args);
  if (pid.isNil()) return pid;
  return context.runtime.newArray(pid, context.getLastExitStatus());
}

相关文章

微信公众号

最新文章

更多

Ruby类方法