org.jruby.RubyClass.callMethod()方法的使用及代码示例

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

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

RubyClass.callMethod介绍

暂无

代码示例

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public void unregisterAll() {
  getConverterFactory()
    .callMethod("unregister_all");
}

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

@JRubyMethod
public IRubyObject opendir(ThreadContext context, Block block) {
  return context.runtime.getDir().callMethod(context, "open", new IRubyObject[] { path },
      block);
}

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

@JRubyMethod
public IRubyObject make_symlink(ThreadContext context, IRubyObject old) {
  IRubyObject[] args = new IRubyObject[] { old, path };
  return context.runtime.getFile().callMethod(context, "symlink", args);
}

代码示例来源:origin: asciidoctor/asciidoctorj

private static void handleContentModelAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(ContentModel.class)) {
    ContentModel contentModel = processor.getAnnotation(ContentModel.class);
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("content_model"),
        rubyRuntime.newSymbol(contentModel.value().substring(1))
    });
  }
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

private static void handleNameAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(Name.class)) {
    Name name = processor.getAnnotation(Name.class);
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("name"),
        rubyRuntime.newString(name.value())
    });
  }
}

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

@JRubyMethod(alias = "fnmatch?", required = 1, optional = 1)
public IRubyObject fnmatch(ThreadContext context, IRubyObject[] args) {
  args = insertPath(args, 1);
  return context.runtime.getFile().callMethod(context, "fnmatch?", args);
}

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

@JRubyMethod
public IRubyObject make_symlink(ThreadContext context, IRubyObject old) {
  IRubyObject[] args = new IRubyObject[] { old, getPath()};
  return context.runtime.getFile().callMethod(context, "symlink", args);
}

代码示例来源:origin: asciidoctor/asciidoctorj

private static void handleNameAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(Name.class)) {
    Name name = processor.getAnnotation(Name.class);
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("name"),
        rubyRuntime.newString(name.value())
    });
  }
}

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

@JRubyMethod
public IRubyObject make_link(ThreadContext context, IRubyObject old) {
  IRubyObject[] args = new IRubyObject[] { old, getPath()};
  return context.runtime.getFile().callMethod(context, "link", args);
}

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

@JRubyMethod
public IRubyObject opendir(ThreadContext context, Block block) {
  return context.runtime.getDir().callMethod(context, "open", new IRubyObject[] { getPath()},
      block);
}

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

@JRubyMethod
public IRubyObject make_symlink(ThreadContext context, IRubyObject old) {
  IRubyObject[] args = new IRubyObject[] { old, getPath()};
  return context.runtime.getFile().callMethod(context, "symlink", args);
}

代码示例来源:origin: asciidoctor/asciidoctorj

private static void handleLocationAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(Location.class)) {
    Location location = processor.getAnnotation(Location.class);
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("location"),
        rubyRuntime.newSymbol(location.value().optionValue().substring(1))
    });
  }
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

private static void handleLocationAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(Location.class)) {
    Location location = processor.getAnnotation(Location.class);
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("location"),
        rubyRuntime.newSymbol(location.value().optionValue().substring(1))
    });
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(DefaultAttribute.class)) {
    DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class);
    RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime);
    defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value());
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("default_attrs"),
        defaultAttrs
    });
  }
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(DefaultAttribute.class)) {
    DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class);
    RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime);
    defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value());
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("default_attrs"),
        defaultAttrs
    });
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

static ReaderImpl createReader(Ruby runtime, List<String> lines) {
  RubyArray rubyLines = runtime.newArray(lines.size());
  for (String line : lines) {
    rubyLines.add(runtime.newString(line));
  }
  RubyClass readerClass = runtime.getModule("Asciidoctor").getClass("Reader");
  return new ReaderImpl(readerClass.callMethod("new", rubyLines));
}

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

@JRubyMethod
public IRubyObject each_entry(ThreadContext context, Block block) {
  if (block.isGiven()) {
    // TODO: yield block while iterating
    RubyArray entries = callMethod(context, "entries").convertToArray();
    entries.each(context, block);
    return context.nil;
  } else {
    return context.runtime.getDir().callMethod(context, "foreach");
  }
}

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

@JRubyMethod
public IRubyObject each_entry(ThreadContext context, Block block) {
  if (block.isGiven()) {
    // TODO: yield block while iterating
    RubyArray entries = callMethod(context, "entries").convertToArray();
    entries.each(context, block);
    return context.nil;
  } else {
    return context.runtime.getDir().callMethod(context, "foreach");
  }
}

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

@JRubyMethod
public IRubyObject sub_ext(ThreadContext context, IRubyObject newExt) {
  IRubyObject ext = context.runtime.getFile().callMethod(context, "extname", getPath());
  IRubyObject newPath = getPath().chomp(context, ext).callMethod(context, "+", newExt);
  return newInstance(context, newPath);
}

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

@JRubyMethod(name = "empty?")
public IRubyObject empty_p(ThreadContext context) {
  RubyModule fileTest = context.runtime.getFileTest();
  if (fileTest.callMethod(context, "directory?", getPath()).isTrue()) {
    return context.runtime.getDir().callMethod(context, "empty?", getPath());
  } else {
    return fileTest.callMethod(context, "empty?", getPath());
  }
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法