Module: Types::Generic

Included in:
Array, Block, Boolean, Class, Class, Decimal, Enumerator, Float, Hash, Integer, Interface, Lambda, Method, Named, Nil, Numeric, String, Symbol, Tuple
Defined in:
lib/types/generic.rb

Overview

An extension module which allows constructing Any types using the | operator.

type = Types::String | Types::Integer

Instance Method Summary collapse

Instance Method Details

#composite? ⇒ Boolean

Returns:



29
30
31
# File 'lib/types/generic.rb', line 29

def composite?
	false
end

#to_rbs ⇒ Object

By default, this is the same as to_s, but can be overridden by composite types.



24
25
26
# File 'lib/types/generic.rb', line 24

def to_rbs
	to_s
end

#to_s ⇒ Object



34
35
36
# File 'lib/types/generic.rb', line 34

def to_s
	self.name.rpartition("::").last
end

#|(other) ⇒ Object

Create an instance of Any with the arguments as types.



18
19
20
# File 'lib/types/generic.rb', line 18

def | other
	Any.new([self, other])
end