Module: RBS::Types::_TypeBase

Includes:
_ToJson
Included in:
Alias, Bases::Base, ClassInstance, ClassSingleton, Interface, Intersection, Literal, Optional, Proc, Record, Tuple, Union, Variable
Defined in:
sig/types.rbs

Overview

_TypeBase interface represents the operations common to all of the types.

Instance Method Summary collapse

Instance Method Details

#each_typevoid #each_typeEnumerator[t, void]

Yields all direct sub types included in the type. It doesn't yield the type itself.

parse("Hash[String, Array[Symbol]]").each_type do |ty|
  ...       # Yields String and Array[Symbol]
end

Overloads:

  • #each_typevoid

    This method returns an undefined value.

  • #each_typeEnumerator[t, void]

    Returns:

    • (Enumerator[t, void])

Yields:

Yield Parameters:

  • arg0 (t)

Yield Returns:

  • (void)


27
28
# File 'sig/types.rbs', line 27

def each_type: () { (t) -> void } -> void
| () -> Enumerator[t, void]

#free_variablesSet[Symbol]

Returns names of free variables of a type. You can pass a Set instance to add the free variables to the set to avoid Set object allocation.

Parameters:

  • (Set[Symbol])

Returns:

  • (Set[Symbol])


9
# File 'sig/types.rbs', line 9

def free_variables: (?Set[Symbol]) -> Set[Symbol]

#has_classish_type?Boolean

Returns true if it has instance or class types

Returns:

  • (Boolean)


50
# File 'sig/types.rbs', line 50

def has_classish_type?: () -> bool

#has_self_type?Boolean

Returns true if it has self type

Returns:

  • (Boolean)


47
# File 'sig/types.rbs', line 47

def has_self_type?: () -> bool

#map_type_name {|arg0, arg1, arg2| ... } ⇒ t

Maps type names included in the type and returns new instance of type.

Yields:

Yield Parameters:

Yield Returns:

Returns:

  • (t)


16
# File 'sig/types.rbs', line 16

def map_type_name: () { (TypeName, Location[untyped, untyped]?, t) -> TypeName } -> t

#subt

Receives a substitution and returns a new type applied the substitution.

Parameters:

Returns:

  • (t)


13
# File 'sig/types.rbs', line 13

def sub: (Substitution) -> t

#to_sString

Returns a String representation. level is used internally.

parse("String").to_s               # => "String"
parse("String | Integer").to_s()   # => "String | Integer"
parse("String | Integer").to_s(1)  # => "(String | Integer)"

Parameters:

  • level (Integer)

Returns:

  • (String)


43
# File 'sig/types.rbs', line 43

def to_s: (?Integer level) -> String

#with_nonreturn_void?Boolean

Returns true if it has void types other than return position

  • The function return type is a return position (() -> void)
  • Generic parameter is a return position (Enumerator[Integer, void])

Returns:

  • (Boolean)


57
# File 'sig/types.rbs', line 57

def with_nonreturn_void?: () -> bool