@JRubyMethod public IRubyObject concat(ThreadContext context, IRubyObject list) { if (list instanceof RubyArray) { checkArrayElementType(context, (RubyArray) list); this.storage.addAll((RubyArray) list); } else { RubyRepeatedField repeatedField = (RubyRepeatedField) list; if (! fieldType.equals(repeatedField.fieldType) || (typeClass != null && ! typeClass.equals(repeatedField.typeClass))) throw context.runtime.newArgumentError("Attempt to append RepeatedField with different element type."); this.storage.addAll((RubyArray) repeatedField.toArray(context)); } return this.storage; }
@JRubyMethod(name = {"+"}) public IRubyObject plus(ThreadContext context, IRubyObject list) { RubyRepeatedField dup = (RubyRepeatedField) dup(context); if (list instanceof RubyArray) { checkArrayElementType(context, (RubyArray) list); dup.storage.addAll((RubyArray) list); } else { RubyRepeatedField repeatedField = (RubyRepeatedField) list; if (! fieldType.equals(repeatedField.fieldType) || (typeClass != null && ! typeClass.equals(repeatedField.typeClass))) throw context.runtime.newArgumentError("Attempt to append RepeatedField with different element type."); dup.storage.addAll((RubyArray) repeatedField.toArray(context)); } return dup; }
private RubyArray convertToRubyArray(List<Integer> list) { RubyArray array = RubyArray.newEmptyArray(runtime); array.addAll(list); return array; }
private RubyArray convertToRubyArray(List<Integer> list) { RubyArray array = RubyArray.newEmptyArray(runtime); array.addAll(list); return array; }
/** rb_mod_class_variables * */ @JRubyMethod(name = "class_variables", compat = RUBY1_8) public RubyArray class_variables(ThreadContext context) { Ruby runtime = context.runtime; RubyArray ary = runtime.newArray(); Collection<String> names = classVariablesCommon(); ary.addAll(names); return ary; }
private void updateArgvByJavaObject() { RubyArray ary = RubyArray.newArray(receiver.getRuntime()); if (javaObject instanceof Collection) { ary.addAll((Collection)javaObject); } else if (javaObject instanceof String[]) { for (String s : (String[])javaObject) { ary.add(s); } } irubyObject = ary; }
@JRubyMethod(name = "constants", compat = RUBY1_8) public RubyArray constants(ThreadContext context) { Ruby runtime = context.runtime; RubyArray array = runtime.newArray(); Collection<String> constantNames = constantsCommon(runtime, true, true); array.addAll(constantNames); return array; }
/** rb_mod_class_variables * */ @JRubyMethod(name = "class_variables", compat = RUBY1_8) public RubyArray class_variables(ThreadContext context) { Ruby runtime = context.runtime; RubyArray ary = runtime.newArray(); Collection<String> names = classVariablesCommon(); ary.addAll(names); return ary; }
@JRubyMethod(name = "constants", compat = RUBY1_8) public RubyArray constants(ThreadContext context) { Ruby runtime = context.runtime; RubyArray array = runtime.newArray(); Collection<String> constantNames = constantsCommon(runtime, true, true); array.addAll(constantNames); return array; }
private void updateArgvByJavaObject() { RubyArray ary = RubyArray.newArray(receiver.getRuntime()); if (javaObject instanceof Collection) { ary.addAll((Collection)javaObject); } else if (javaObject instanceof String[]) { for (String s : (String[])javaObject) { ary.add(s); } } irubyObject = ary; }
@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, INLINE_CLASS, parameters); }
@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, INLINE_CLASS, parameters); }
/** * Injects ARGV values to a parsed Ruby script. This method is * invoked during EvalUnit#run() is executed. * * @param runtime is environment where a variable injection occurs * @param receiver is the instance that will have variable injection. */ @Override public void inject() { final Ruby runtime = getRuntime(); final RubyArray argv = RubyArray.newArray(runtime); if ( javaObject instanceof Collection ) { argv.addAll( (Collection) javaObject ); } else if ( javaObject instanceof String[] ) { for ( String str : (String[]) javaObject ) argv.add(str); } this.irubyObject = argv; fromRuby = true; RubyModule rubyModule = getRubyClass(runtime); // SSS FIXME: With rubyclass stack gone, this needs a replacement if (rubyModule == null) rubyModule = null; // receiver.getRuntime().getCurrentContext().getRubyClass(); if (rubyModule == null) return; rubyModule.storeConstant(name, argv); runtime.getConstantInvalidator(name).invalidate(); }
/** * Injects ARGV values to a parsed Ruby script. This method is * invoked during EvalUnit#run() is executed. * * @param runtime is environment where a variable injection occurs * @param receiver is the instance that will have variable injection. */ @Override public void inject() { final Ruby runtime = getRuntime(); final RubyArray argv = RubyArray.newArray(runtime); if ( javaObject instanceof Collection ) { argv.addAll( (Collection) javaObject ); } else if ( javaObject instanceof String[] ) { for ( String str : (String[]) javaObject ) argv.add(str); } this.irubyObject = argv; fromRuby = true; RubyModule rubyModule = getRubyClass(runtime); // SSS FIXME: With rubyclass stack gone, this needs a replacement if (rubyModule == null) rubyModule = null; // receiver.getRuntime().getCurrentContext().getRubyClass(); if (rubyModule == null) return; rubyModule.storeConstant(name, argv); runtime.getConstantInvalidator(name).invalidate(); }