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

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

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

Ruby.getGenerator介绍

暂无

代码示例

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

@JRubyMethod(visibility = Visibility.PRIVATE)
public IRubyObject initialize_copy(ThreadContext context, IRubyObject other) {
  if (!(other instanceof RubyGenerator)) {
    throw context.runtime.newTypeError(other, context.runtime.getGenerator());
  }
  checkFrozen();
  this.proc = ((RubyGenerator)other).proc;
  return this;
}

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

@JRubyMethod(visibility = Visibility.PRIVATE)
public IRubyObject initialize_copy(ThreadContext context, IRubyObject other) {
  if (!(other instanceof RubyGenerator)) {
    throw context.runtime.newTypeError(other, context.runtime.getGenerator());
  }
  checkFrozen();
  this.proc = ((RubyGenerator)other).proc;
  return this;
}

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

@JRubyMethod(name = "initialize", visibility = PRIVATE, rest = true)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  IRubyObject object;
  IRubyObject method = runtime.newSymbol("each");
  IRubyObject size = null;
  if (block.isGiven()) {
    Arity.checkArgumentCount(runtime, args, 0, 1);
    if (args.length > 0) {
      size = args[0];
      args = Arrays.copyOfRange(args, 1, args.length);
      if ( ! (size.isNil() || size.respondsTo("call")) &&
         ! (runtime.getFloat().isInstance(size) && ((RubyFloat) size).getDoubleValue() == Float.POSITIVE_INFINITY) &&
         ! (size instanceof RubyInteger) ) {
        throw runtime.newTypeError(size, runtime.getInteger());
      }
    }
    object = runtime.getGenerator().newInstance(context, IRubyObject.NULL_ARRAY, block);
  } else {
    Arity.checkArgumentCount(runtime, args, 1, -1);
    // TODO need a deprecation WARN here, but can't add it until ruby/jruby/kernel20/enumerable.rb is deleted or stops calling this without a block
    object = args[0];
    args = Arrays.copyOfRange(args, 1, args.length);
    if (args.length > 0) {
      method = args[0];
      args = Arrays.copyOfRange(args, 1, args.length);
    }
  }
  return initialize(runtime, object, method, args, size, null);
}

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

@JRubyMethod(name = "initialize", visibility = PRIVATE, rest = true)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  IRubyObject object;
  IRubyObject method = runtime.newSymbol("each");
  IRubyObject size = null;
  if (block.isGiven()) {
    Arity.checkArgumentCount(runtime, args, 0, 1);
    if (args.length > 0) {
      size = args[0];
      args = Arrays.copyOfRange(args, 1, args.length);
      if ( ! (size.isNil() || size.respondsTo("call")) &&
         ! (runtime.getFloat().isInstance(size) && ((RubyFloat) size).getDoubleValue() == Float.POSITIVE_INFINITY) &&
         ! (size instanceof RubyInteger) ) {
        throw runtime.newTypeError(size, runtime.getInteger());
      }
    }
    object = runtime.getGenerator().newInstance(context, IRubyObject.NULL_ARRAY, block);
  } else {
    Arity.checkArgumentCount(runtime, args, 1, -1);
    // TODO need a deprecation WARN here, but can't add it until ruby/jruby/kernel20/enumerable.rb is deleted or stops calling this without a block
    object = args[0];
    args = Arrays.copyOfRange(args, 1, args.length);
    if (args.length > 0) {
      method = args[0];
      args = Arrays.copyOfRange(args, 1, args.length);
    }
  }
  return initialize(runtime, object, method, args, size, null);
}

相关文章

微信公众号

最新文章

更多

Ruby类方法