Package org.jruby.ast.util
Class ArgsUtil
java.lang.Object
org.jruby.ast.util.ArgsUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final IRubyObject[]private static final IRubyObject[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intarrayLength(IRubyObject node) static RubyArrayconvertToRubyArray(Ruby runtime, IRubyObject value, boolean coerce) This name may be a bit misleading, since this also attempts to coerce array behavior using to_ary.static RubyArrayconvertToRubyArrayWithCoerce(Ruby runtime, IRubyObject value) static IRubyObjectextractKeywordArg(ThreadContext context, String keyword, RubyHash opts) Semi-deprecated, kept for compatibility.static IRubyObjectextractKeywordArg(ThreadContext context, String keyword, IRubyObject arg) Semi-deprecated, kept for compatibility.static IRubyObjectextractKeywordArg(ThreadContext context, String keyword, IRubyObject... args) Semi-deprecated, kept for compatibility.static IRubyObjectextractKeywordArg(ThreadContext context, RubyHash options, String validKey) static IRubyObject[]extractKeywordArgs(ThreadContext context, RubyHash options, String... validKeys) Check that the given kwargs hash doesn't contain any keys other than those which are given as valid.static IRubyObject[]extractKeywordArgs(ThreadContext context, IRubyObject[] args, String... validKeys) static IRubyObject[]extractKeywordArgs(ThreadContext context, IRubyObject maybeKwargs, String... validKeys) static IRubyObjectgetOptionsArg(Ruby runtime, IRubyObject arg) static IRubyObjectgetOptionsArg(Ruby runtime, IRubyObject... args) static IRubyObjectgetOptionsArg(Ruby runtime, IRubyObject arg, boolean raise)
-
Field Details
-
NULL_1
-
NULL_2
-
-
Constructor Details
-
ArgsUtil
public ArgsUtil()
-
-
Method Details
-
convertToRubyArray
This name may be a bit misleading, since this also attempts to coerce array behavior using to_ary.- Parameters:
runtime- The JRuby runtimevalue- The value to convertcoerce- Whether to coerce using to_ary or just wrap with an array
-
convertToRubyArrayWithCoerce
-
arrayLength
-
getOptionsArg
-
getOptionsArg
-
getOptionsArg
-
extractKeywordArgs
public static IRubyObject[] extractKeywordArgs(ThreadContext context, RubyHash options, String... validKeys) Check that the given kwargs hash doesn't contain any keys other than those which are given as valid.- Parameters:
context- The context to execute inoptions- A RubyHash of options to extract kwargs fromvalidKeys- A list of valid kwargs keys.- Returns:
- an array of objects corresponding to the given keys.
-
extractKeywordArgs
public static IRubyObject[] extractKeywordArgs(ThreadContext context, IRubyObject[] args, String... validKeys) -
extractKeywordArgs
public static IRubyObject[] extractKeywordArgs(ThreadContext context, IRubyObject maybeKwargs, String... validKeys) -
extractKeywordArg
public static IRubyObject extractKeywordArg(ThreadContext context, RubyHash options, String validKey) - Parameters:
context-options-validKey- the keyword to extract- Returns:
- null if key not within options, otherwise
options[:keyword]
-
extractKeywordArg
Semi-deprecated, kept for compatibility. Compared toextractKeywordArg(ThreadContext, RubyHash, String)does not validate options!- Parameters:
context-keyword-opts-- Returns:
- nil if key not within options (no way to distinguish a key: nil and missing key)
-
extractKeywordArg
Semi-deprecated, kept for compatibility. Compared toextractKeywordArg(ThreadContext, RubyHash, String)does not validate options!- Parameters:
context-keyword-arg-- Returns:
- nil if key not within options (no way to distinguish a key: nil and missing key)
-
extractKeywordArg
public static IRubyObject extractKeywordArg(ThreadContext context, String keyword, IRubyObject... args) Semi-deprecated, kept for compatibility. Compared toextractKeywordArg(ThreadContext, RubyHash, String)does not validate options!- Parameters:
context-keyword-args-- Returns:
- nil if key not within options (no way to distinguish a key: nil and missing key)
-