Java Code Examples for org.jruby.Ruby#newArray()
The following examples show how to use
org.jruby.Ruby#newArray() .
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: JRubyProcessor.java From asciidoctorj with Apache License 2.0 | 6 votes |
@Override public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes, Map<Object, Object> options) { Ruby rubyRuntime = JRubyRuntimeContext.get(parent); options.put(Options.ATTRIBUTES, attributes); RubyHash convertMapToRubyHashWithSymbols = RubyHashUtil.convertMapToRubyHashWithSymbolsIfNecessary(rubyRuntime, options); RubyArray rubyText = rubyRuntime.newArray(); rubyText.addAll(text); IRubyObject[] parameters = { ((ContentNodeImpl) parent).getRubyObject(), RubyUtils.toSymbol(rubyRuntime, context), rubyText, convertMapToRubyHashWithSymbols}; return (PhraseNode) NodeConverter.createASTNode(rubyRuntime, NodeConverter.NodeType.INLINE_CLASS, parameters); }
Example 2
Source File: PigJrubyLibrary.java From spork with Apache License 2.0 | 5 votes |
/** * A type specific conversion routine. * * @param ruby the Ruby runtime to create objects in * @param object object to convert * @return analogous Ruby type * @throws ExecException object contained an object that could not convert */ public static RubyArray pigToRuby(Ruby ruby, Tuple object) throws ExecException{ RubyArray rubyArray = ruby.newArray(); for (Object o : object.getAll()) rubyArray.add(pigToRuby(ruby, o)); return rubyArray; }
Example 3
Source File: AbstractProcessorProxy.java From asciidoctorj with Apache License 2.0 | 5 votes |
private static void handleContextsAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Contexts.class)) { Contexts contexts = processor.getAnnotation(Contexts.class); RubyArray contextList = rubyRuntime.newArray(); for (String value : contexts.value()) { contextList.add(rubyRuntime.newSymbol(value.substring(1))); } rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("contexts"), contextList }); } }
Example 4
Source File: ReaderImpl.java From asciidoctorj with Apache License 2.0 | 5 votes |
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)); }
Example 5
Source File: JRubyProcessor.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Override public Row createTableRow(Table parent) { Ruby rubyRuntime = JRubyRuntimeContext.get(parent); RubyArray rubyRow = rubyRuntime.newArray(); return new RowImpl(rubyRow); }