org.jruby.RubyBoolean Java Examples
The following examples show how to use
org.jruby.RubyBoolean.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarathonRuby.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private static RubyHash map2hash(Ruby ruby, Map<String, Object> ourCaps) { RubyHash hash = new RubyHash(ruby); Set<String> keySet = ourCaps.keySet(); for (String key : keySet) { RubySymbol keySym = RubySymbol.newSymbol(ruby, key); Object v = ourCaps.get(key); if (v instanceof String) { hash.put(keySym, RubyString.newString(ruby, (String) v)); } else if (v instanceof Boolean) { hash.put(keySym, RubyBoolean.newBoolean(ruby, (boolean) v)); } else if (v instanceof List) { hash.put(keySym, map2list(ruby, (List<?>) v)); } else { hash.put(keySym, map2hash(ruby, (Map<String, Object>) v)); } } return hash; }
Example #2
Source File: MarathonRuby.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private static RubyArray map2list(Ruby ruby, List<?> list) { RubyArray array = new RubyArray(ruby, list.size()); int index = 0; for (Object v : list) { if (v instanceof String) { array.set(index++, RubyString.newString(ruby, (String) v)); } else if (v instanceof Boolean) { array.set(index++, RubyBoolean.newBoolean(ruby, (boolean) v)); } else if (v instanceof List) { array.set(index++, map2list(ruby, (List<?>) v)); } else { array.set(index++, map2hash(ruby, (Map<String, Object>) v)); } } return array; }
Example #3
Source File: RubyDataByteArray.java From spork with Apache License 2.0 | 5 votes |
/** * Overrides equality leveraging DataByteArray's equality. * * @param context the context the method is being executed in * @param arg a RubyDataByteArray against which to test equality * @return true if they are equal, false otherwise */ @JRubyMethod(name = {"eql?", "=="}) public RubyBoolean equals(ThreadContext context, IRubyObject arg) { Ruby runtime = context.getRuntime(); if (arg instanceof RubyDataByteArray) { return RubyBoolean.newBoolean(runtime, internalDBA.equals(((RubyDataByteArray)arg).getDBA())); } else { return runtime.getFalse(); } }
Example #4
Source File: PigJrubyLibrary.java From spork with Apache License 2.0 | 5 votes |
/** * This method facilitates conversion from Ruby objects to Pig objects. This is * a general class which detects the subclass and invokes the appropriate conversion * routine. It will fail on an unsupported datatype. * * @param rbObject a Ruby object to convert * @return the Pig analogue of the Ruby object * @throws ExecException if rbObject is not of a known type that can be converted */ @SuppressWarnings("unchecked") public static Object rubyToPig(IRubyObject rbObject) throws ExecException { if (rbObject == null || rbObject instanceof RubyNil) { return null; } else if (rbObject instanceof RubyArray) { return rubyToPig((RubyArray)rbObject); } else if (rbObject instanceof RubyHash) { return rubyToPig((RubyHash)rbObject); } else if (rbObject instanceof RubyString) { return rubyToPig((RubyString)rbObject); } else if (rbObject instanceof RubyBignum) { return rubyToPig((RubyBignum)rbObject); } else if (rbObject instanceof RubyFixnum) { return rubyToPig((RubyFixnum)rbObject); } else if (rbObject instanceof RubyFloat) { return rubyToPig((RubyFloat)rbObject); } else if (rbObject instanceof RubyInteger) { return rubyToPig((RubyInteger)rbObject); } else if (rbObject instanceof RubyDataBag) { return rubyToPig((RubyDataBag)rbObject); } else if (rbObject instanceof RubyDataByteArray) { return rubyToPig((RubyDataByteArray)rbObject); } else if (rbObject instanceof RubySchema) { return rubyToPig((RubySchema)rbObject); } else if (rbObject instanceof RubyBoolean) { return rubyToPig((RubyBoolean)rbObject); } else { throw new ExecException("Cannot cast into any pig supported type: " + rbObject.getClass().getName()); } }
Example #5
Source File: DocumentImpl.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Override public Title getStructuredDoctitle() { Ruby runtime = getRubyObject().getRuntime(); RubyHash options = RubyHash.newHash(runtime); RubySymbol partitioned = RubySymbol.newSymbol(runtime, "partition"); options.put(partitioned, RubyBoolean.newBoolean(runtime, true)); Object doctitle = getRubyProperty("doctitle", options); return toJava((IRubyObject) doctitle, Title.class); }
Example #6
Source File: WhenDocumentIsRenderedWithPreloading.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void coderay_gem_should_be_preloaded() { Map<String, Object> options = OptionsBuilder.options() .attributes(AttributesBuilder.attributes().sourceHighlighter("coderay").get()).asMap(); ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options); RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'coderay'"); assertThat(evalScriptlet.isFalse(), is(true)); }
Example #7
Source File: WhenDocumentIsRenderedWithPreloading.java From asciidoctorj with Apache License 2.0 | 5 votes |
@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)); }
Example #8
Source File: WhenDocumentIsRenderedWithPreloading.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void data_uri_gem_should_be_preloaded() { Map<String, Object> options = OptionsBuilder.options() .attributes(AttributesBuilder.attributes().dataUri(true).get()).asMap(); ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options); RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'base64'"); assertThat(evalScriptlet.isFalse(), is(true)); }
Example #9
Source File: WhenDocumentIsRenderedWithPreloading.java From asciidoctorj with Apache License 2.0 | 3 votes |
@Test public void erubis_gem_should_be_preloaded() { Map<String, Object> options = OptionsBuilder.options().eruby("erubis").asMap(); ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options); RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'erubis'"); assertThat(evalScriptlet.isFalse(), is(true)); }
Example #10
Source File: WhenDocumentIsRenderedWithPreloading.java From asciidoctorj with Apache License 2.0 | 3 votes |
@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)); }
Example #11
Source File: WhenDocumentIsRenderedWithPreloading.java From asciidoctorj with Apache License 2.0 | 3 votes |
@Test public void template_dir_should_preload_tilt() { Map<String, Object> options = OptionsBuilder.options().templateDir(new File(".")).asMap(); ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options); RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'tilt'"); assertThat(evalScriptlet.isFalse(), is(true)); }
Example #12
Source File: RubyDataBag.java From spork with Apache License 2.0 | 2 votes |
/** * This returns whether the encapsulated DatBag is distinct, per the distinct setting. * * @param context the context the method is being executed in * @return true if it the encapsulated is distinct, false otherwise */ @JRubyMethod(name = {"distinct?", "is_distinct?"}) public RubyBoolean isDistinct(ThreadContext context) { return RubyBoolean.newBoolean(context.getRuntime(), internalDB.isDistinct()); }
Example #13
Source File: RubyDataBag.java From spork with Apache License 2.0 | 2 votes |
/** * This returns whether the encapsulated DatBag is distinct, per the sorted setting. * * @param context the context the method is being executed in * @return true if it the encapsulated is sorted, false otherwise */ @JRubyMethod(name = {"sorted?", "is_sorted?"}) public RubyBoolean isSorted(ThreadContext context) { return RubyBoolean.newBoolean(context.getRuntime(), internalDB.isSorted()); }
Example #14
Source File: RubyDataBag.java From spork with Apache License 2.0 | 2 votes |
/** * This method returns whether or not the encapsulated DataBag is empty. * * @param context the context the method is being executed in i @return true if the encapsulated DAtaBag is empty, false otherwise */ @JRubyMethod(name = "empty?") public RubyBoolean isEmpty(ThreadContext context) { return RubyBoolean.newBoolean(context.getRuntime(), internalDB.size() == 0); }
Example #15
Source File: PigJrubyLibrary.java From spork with Apache License 2.0 | 2 votes |
/** * A type specific conversion routine. * * @param rbObject object to convert * @return analogous Pig type */ public static Boolean rubyToPig(RubyBoolean rbObject) { return rbObject.isTrue(); }
Example #16
Source File: PigJrubyLibrary.java From spork with Apache License 2.0 | 2 votes |
/** * A type specific conversion routine. * * @param ruby the Ruby runtime to create objects in * @param object object to convert * @return analogous Ruby type */ public static RubyBoolean pigToRuby(Ruby ruby, Boolean object) { return RubyBoolean.newBoolean(ruby, object.booleanValue()); }