Package org.jruby.ast.util
Class ArgsUtil
java.lang.Object
org.jruby.ast.util.ArgsUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RubyHash.VisitorWithState<Set<RubySymbol>> static final RubyHash.VisitorWithState<RubySymbol> -
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 IRubyObjectextractKeywordArg(ThreadContext context, IRubyObject maybeKwargs, 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) Deprecated.static IRubyObject[]extractKeywordArgs(ThreadContext context, IRubyObject maybeKwargs, String... validKeys) static RubyHashextractKeywords(IRubyObject possiblyKeywordArg) static IRubyObjectgetFreezeOpt(ThreadContext context, IRubyObject maybeOpts) static IRubyObjectgetOptionsArg(Ruby runtime, IRubyObject arg) Deprecated.static IRubyObjectgetOptionsArg(Ruby runtime, IRubyObject... args) static IRubyObjectgetOptionsArg(Ruby runtime, IRubyObject arg, boolean raise) static IRubyObjectgetOptionsArg(ThreadContext context, IRubyObject arg) static booleanhasExceptionOption(ThreadContext context, IRubyObject options, boolean defaultValue)
-
Field Details
-
SINGLE_KEY_CHECK_VISITOR
-
MULTI_KEY_CHECK_VISITOR
-
-
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
-
hasExceptionOption
public static boolean hasExceptionOption(ThreadContext context, IRubyObject options, boolean defaultValue) -
getOptionsArg
-
getOptionsArg
Deprecated. -
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
@Deprecated public static IRubyObject[] extractKeywordArgs(ThreadContext context, IRubyObject[] args, String... validKeys) Deprecated. -
extractKeywordArgs
public static IRubyObject[] extractKeywordArgs(ThreadContext context, IRubyObject maybeKwargs, String... validKeys) -
extractKeywordArg
public static IRubyObject extractKeywordArg(ThreadContext context, IRubyObject maybeKwargs, String validKey) -
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)
-
extractKeywords
-
getFreezeOpt
-