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 int
arrayLength
(IRubyObject node) static RubyArray
convertToRubyArray
(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 RubyArray
convertToRubyArrayWithCoerce
(Ruby runtime, IRubyObject value) static IRubyObject
extractKeywordArg
(ThreadContext context, String keyword, RubyHash opts) Semi-deprecated, kept for compatibility.static IRubyObject
extractKeywordArg
(ThreadContext context, String keyword, IRubyObject arg) Semi-deprecated, kept for compatibility.static IRubyObject
extractKeywordArg
(ThreadContext context, String keyword, IRubyObject... args) Semi-deprecated, kept for compatibility.static IRubyObject
extractKeywordArg
(ThreadContext context, RubyHash options, String validKey) static IRubyObject
extractKeywordArg
(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 RubyHash
extractKeywords
(IRubyObject possiblyKeywordArg) static IRubyObject
getFreezeOpt
(ThreadContext context, IRubyObject maybeOpts) static IRubyObject
getOptionsArg
(Ruby runtime, IRubyObject arg) Deprecated.static IRubyObject
getOptionsArg
(Ruby runtime, IRubyObject... args) static IRubyObject
getOptionsArg
(Ruby runtime, IRubyObject arg, boolean raise) static IRubyObject
getOptionsArg
(ThreadContext context, IRubyObject arg) static boolean
hasExceptionOption
(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
-