Top Fields Constructors Methods
org.jruby.ast.util

public final Class ArgsUtil

extends Object
Class Inheritance
Imports
org.jruby.Ruby, .RubyArray, .RubyHash, .RubySymbol, org.jruby.api.Convert, org.jruby.runtime.ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.TypeConverter, java.util.HashSet, .Set

Field Summary

Modifier and TypeField and Description
public static final RubyHash.VisitorWithState<Set<RubySymbol>>
private static final IRubyObject[]
private static final IRubyObject[]
private static final IRubyObject[]
public static final RubyHash.VisitorWithState<RubySymbol>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static int
public static RubyArray<T extends IRubyObject>
convertToRubyArray(Ruby
The JRuby runtime
runtime
,
IRubyObject
The value to convert
value
,
boolean
Whether to coerce using to_ary or just wrap with an array
coerce
)

This name may be a bit misleading, since this also attempts to coerce array behavior using to_ary.

public static RubyArray<T extends IRubyObject>
public static IRubyObject
extractKeywordArg(ThreadContext context, IRubyObject maybeKwargs, String validKey)

public static IRubyObject

Returns:

null if key not within options, otherwise options[:keyword]
extractKeywordArg
(ThreadContext context, final RubyHash options, String
the keyword to extract
validKey
)

Same as extractKeywordArgs(ThreadContext, RubyHash, String...).

public static IRubyObject

Returns:

nil if key not within options (no way to distinguish a key: nil and missing key)
extractKeywordArg
(ThreadContext context, String keyword, final RubyHash opts)

Semi-deprecated, kept for compatibility.

public static IRubyObject

Returns:

nil if key not within options (no way to distinguish a key: nil and missing key)
extractKeywordArg
(ThreadContext context, String keyword, IRubyObject arg)

Semi-deprecated, kept for compatibility.

public static IRubyObject

Returns:

nil if key not within options (no way to distinguish a key: nil and missing key)
extractKeywordArg
(ThreadContext context, String keyword, IRubyObject... args)

Semi-deprecated, kept for compatibility.

public static IRubyObject[]

Returns:

an array of objects corresponding to the given keys.
extractKeywordArgs
(ThreadContext
The context to execute in
context
,
final RubyHash
A RubyHash of options to extract kwargs from
options
,
String...
A list of valid kwargs keys.
validKeys
)

Check that the given kwargs hash doesn't contain any keys other than those which are given as valid.

public static IRubyObject[]
extractKeywordArgs(ThreadContext context, IRubyObject[] args, String... validKeys)
Deprecated

public static IRubyObject[]
extractKeywordArgs(ThreadContext context, IRubyObject maybeKwargs, String... validKeys)

public static RubyHash
extractKeywords(IRubyObject possiblyKeywordArg)

public static IRubyObject
public static IRubyObject
getOptionsArg(Ruby runtime, IRubyObject... args)

public static IRubyObject
getOptionsArg(Ruby runtime, IRubyObject arg)
Deprecated since 10.0.

public static IRubyObject
public static IRubyObject
getOptionsArg(Ruby runtime, IRubyObject arg, boolean raise)

public static boolean
hasExceptionOption(ThreadContext context, IRubyObject options, boolean defaultValue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MULTI_KEY_CHECK_VISITORback to summary
public static final RubyHash.VisitorWithState<Set<RubySymbol>> MULTI_KEY_CHECK_VISITOR
NULL_1back to summary
private static final IRubyObject[] NULL_1
NULL_2back to summary
private static final IRubyObject[] NULL_2
NULL_3back to summary
private static final IRubyObject[] NULL_3
SINGLE_KEY_CHECK_VISITORback to summary
public static final RubyHash.VisitorWithState<RubySymbol> SINGLE_KEY_CHECK_VISITOR

Constructor Detail

ArgsUtilback to summary
public ArgsUtil()

Method Detail

arrayLengthback to summary
public static int arrayLength(IRubyObject node)
convertToRubyArrayback to summary
public static RubyArray<T extends IRubyObject> 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.

Parameters
runtime:Ruby

The JRuby runtime

value:IRubyObject

The value to convert

coerce:boolean

Whether to coerce using to_ary or just wrap with an array

convertToRubyArrayWithCoerceback to summary
public static RubyArray<T extends IRubyObject> convertToRubyArrayWithCoerce(Ruby runtime, IRubyObject value)
extractKeywordArgback to summary
public static IRubyObject extractKeywordArg(ThreadContext context, IRubyObject maybeKwargs, String validKey)
extractKeywordArgback to summary
public static IRubyObject extractKeywordArg(ThreadContext context, final RubyHash options, String validKey)

Same as extractKeywordArgs(ThreadContext, RubyHash, String...).

Parameters
validKey:String

the keyword to extract

Returns:IRubyObject

null if key not within options, otherwise options[:keyword]

extractKeywordArgback to summary
public static IRubyObject extractKeywordArg(ThreadContext context, String keyword, final RubyHash opts)

Semi-deprecated, kept for compatibility. Compared to extractKeywordArg(ThreadContext, RubyHash, String) does not validate options!

Returns:IRubyObject

nil if key not within options (no way to distinguish a key: nil and missing key)

extractKeywordArgback to summary
public static IRubyObject extractKeywordArg(ThreadContext context, String keyword, IRubyObject arg)

Semi-deprecated, kept for compatibility. Compared to extractKeywordArg(ThreadContext, RubyHash, String) does not validate options!

Returns:IRubyObject

nil if key not within options (no way to distinguish a key: nil and missing key)

extractKeywordArgback to summary
public static IRubyObject extractKeywordArg(ThreadContext context, String keyword, IRubyObject... args)

Semi-deprecated, kept for compatibility. Compared to extractKeywordArg(ThreadContext, RubyHash, String) does not validate options!

Returns:IRubyObject

nil if key not within options (no way to distinguish a key: nil and missing key)

extractKeywordArgsback to summary
public static IRubyObject[] extractKeywordArgs(ThreadContext context, final 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:ThreadContext

The context to execute in

options:RubyHash

A RubyHash of options to extract kwargs from

validKeys:String[]

A list of valid kwargs keys.

Returns:IRubyObject[]

an array of objects corresponding to the given keys.

extractKeywordArgsback to summary
public static IRubyObject[] extractKeywordArgs(ThreadContext context, IRubyObject[] args, String... validKeys)

Deprecated

Annotations
@Deprecated
extractKeywordArgsback to summary
public static IRubyObject[] extractKeywordArgs(ThreadContext context, IRubyObject maybeKwargs, String... validKeys)
extractKeywordsback to summary
public static RubyHash extractKeywords(IRubyObject possiblyKeywordArg)
getFreezeOptback to summary
public static IRubyObject getFreezeOpt(ThreadContext context, IRubyObject maybeOpts)
getOptionsArgback to summary
public static IRubyObject getOptionsArg(Ruby runtime, IRubyObject... args)
getOptionsArgback to summary
public static IRubyObject getOptionsArg(Ruby runtime, IRubyObject arg)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
getOptionsArgback to summary
public static IRubyObject getOptionsArg(ThreadContext context, IRubyObject arg)
getOptionsArgback to summary
public static IRubyObject getOptionsArg(Ruby runtime, IRubyObject arg, boolean raise)
hasExceptionOptionback to summary
public static boolean hasExceptionOption(ThreadContext context, IRubyObject options, boolean defaultValue)