/** * A type specific conversion routine. * * @param rbObject object to convert * @return analogous Pig type */ public static Boolean rubyToPig(RubyBoolean rbObject) { return rbObject.isTrue(); }
public void marshalTo(MarshalStream output) throws java.io.IOException { output.write(isTrue() ? 'T' : 'F'); } }
@Override public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, RubyHash otherHash) { IRubyObject value2 = otherHash.fastARef(key); if (value2 == null) { // other hash does not contain key throw MISMATCH; } if (!Helpers.rbEql(context, value, value2).isTrue()) { throw MISMATCH; } } };
@Override public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, RubyHash otherHash) { IRubyObject value2 = otherHash.fastARef(key); if (value2 == null) { // other hash does not contain key throw MISMATCH; } if (!Helpers.rbEqual(context, value, value2).isTrue()) { throw MISMATCH; } } };
@Override public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, RubyHash otherHash) { IRubyObject value2 = otherHash.fastARef(key); if (value2 == null) { // other hash does not contain key throw MISMATCH; } if (!Helpers.rbEql(context, value, value2).isTrue()) { throw MISMATCH; } } };
@Override public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, RubyHash otherHash) { IRubyObject value2 = otherHash.fastARef(key); if (value2 == null) { // other hash does not contain key throw MISMATCH; } if (!Helpers.rbEqual(context, value, value2).isTrue()) { throw MISMATCH; } } };
public void run() { if (latch.compareAndSet(false, true)) { if (currentThread.alive_p().isTrue()) { currentThread.internalRaise(new IRubyObject[]{exception, runtime.newString("execution expired")}); } } } };
private static boolean isClosed(ThreadContext context, IRubyObject currentFile) { boolean closed = false; if (!(currentFile instanceof RubyIO)) { closed = currentFile.callMethod(context, "closed?").isTrue(); } else { closed = ((RubyIO)currentFile).closed_p(context).isTrue(); } return closed; }
private static boolean isClosed(ThreadContext context, IRubyObject currentFile) { boolean closed = false; if (!(currentFile instanceof RubyIO)) { closed = currentFile.callMethod(context, "closed?").isTrue(); } else { closed = ((RubyIO)currentFile).closed_p(context).isTrue(); } return closed; }
@JRubyMethod(name = "sync=", required = 1) public IRubyObject set_sync(IRubyObject arg) { sync = ((RubyBoolean) arg).isTrue(); return sync ? getRuntime().getTrue() : getRuntime().getFalse(); }
@JRubyMethod(name = "sync=", required = 1) public IRubyObject set_sync(IRubyObject arg) { sync = ((RubyBoolean) arg).isTrue(); return sync ? getRuntime().getTrue() : getRuntime().getFalse(); }
@JRubyMethod(name = "sync=", required = 1) public IRubyObject set_sync(IRubyObject arg) { sync = ((RubyBoolean) arg).isTrue(); return sync ? getRuntime().getTrue() : getRuntime().getFalse(); }
/** rb_hash_update * */ @JRubyMethod(name = {"merge!", "update"}, required = 1) public RubyHash merge_bang(ThreadContext context, IRubyObject other, Block block) { modify(); final RubyHash otherHash = other.convertToHash(); if (otherHash.empty_p().isTrue()) return this; otherHash.visitAll(context, new MergeVisitor(this), block); return this; }
/** rb_hash_update * */ @JRubyMethod(name = {"merge!", "update"}, required = 1) public RubyHash merge_bang(ThreadContext context, IRubyObject other, Block block) { modify(); final RubyHash otherHash = other.convertToHash(); if (otherHash.empty_p().isTrue()) return this; otherHash.visitAll(context, new MergeVisitor(this), block); return this; }
@JRubyMethod(name = "empty?", meta = true) public static IRubyObject empty_p(ThreadContext context, IRubyObject recv, IRubyObject arg) { Ruby runtime = context.runtime; RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg)); RubyFileStat fileStat = runtime.newFileStat(path.asJavaString(), false); boolean isDirectory = fileStat.directory_p().isTrue(); return runtime.newBoolean(isDirectory && entries(context, recv, arg).getLength() <= 2); }
@JIT @Interp public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObject restKwarg, IRubyObject explicitKwarg) { RubyHash hash = (RubyHash) TypeConverter.checkHashType(context.runtime, restKwarg).dup(); hash.modify(); final RubyHash otherHash = explicitKwarg.convertToHash(); if (otherHash.empty_p().isTrue()) return hash; otherHash.visitAll(context, new KwargMergeVisitor(hash), Block.NULL_BLOCK); return hash; }
@JRubyMethod(name = "empty?", meta = true) public static IRubyObject empty_p(ThreadContext context, IRubyObject recv, IRubyObject arg) { Ruby runtime = context.runtime; RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg)); RubyFileStat fileStat = runtime.newFileStat(path.asJavaString(), false); boolean isDirectory = fileStat.directory_p().isTrue(); return runtime.newBoolean(isDirectory && entries(context, recv, arg).getLength() <= 2); }
@JIT @Interp public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObject restKwarg, IRubyObject explicitKwarg) { RubyHash hash = (RubyHash) TypeConverter.checkHashType(context.runtime, restKwarg).dup(); hash.modify(); final RubyHash otherHash = explicitKwarg.convertToHash(); if (otherHash.empty_p().isTrue()) return hash; otherHash.visitAll(context, new KwargMergeVisitor(hash), Block.NULL_BLOCK); return hash; }
@Test public void not_erubis_gem_should_be_preloaded() { Map<String, Object> options = OptionsBuilder.options().eruby("erb").asMap(); ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options); RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'erubis'"); assertThat(evalScriptlet.isTrue(), is(true)); }
@Test public void not_coderay_gem_should_not_be_preloaded() { Map<String, Object> options = OptionsBuilder.options() .attributes(AttributesBuilder.attributes().sourceHighlighter("pygments").get()).asMap(); ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options); RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'coderay'"); assertThat(evalScriptlet.isTrue(), is(true)); }