Java Code Examples for org.jruby.RubyArray#newArray()

The following examples show how to use org.jruby.RubyArray#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: AbstractProcessorProxy.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
private static void handlePositionalAttributesAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
    Ruby rubyRuntime = rubyClass.getRuntime();
    if (processor.isAnnotationPresent(PositionalAttributes.class)) {
        PositionalAttributes positionalAttributes = processor.getAnnotation(PositionalAttributes.class);
        RubyArray positionalAttrs = RubyArray.newArray(rubyRuntime);
        for (String positionalAttribute : positionalAttributes.value()) {
            positionalAttrs.add(positionalAttribute);
        }
        rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
                rubyRuntime.newSymbol("positional_attrs"),
                positionalAttrs
        });
    }
}
 
Example 2
Source File: RubyHashUtil.java    From asciidoctorj with Apache License 2.0 3 votes vote down vote up
private static IRubyObject toRubyArray(Ruby rubyRuntime, List<Object> values) {

        RubyArray rubyArray = RubyArray.newArray(rubyRuntime, values.size());

        for (Object value : values) {
            rubyArray.add(toRubyObject(rubyRuntime, value));
        }

        return rubyArray;
    }