Class: RBI::Type::Any
Overview
A type that is union of multiple types like ‘T.any(String, Integer)`.
Instance Attribute Summary
Attributes inherited from Composite
Instance Method Summary collapse
-
#nilable? ⇒ Boolean
: -> bool.
-
#to_rbi ⇒ Object
: -> String.
Methods inherited from Composite
Methods inherited from RBI::Type
#==, all, any, anything, attached_class, boolean, class_of, #eql?, generic, #hash, #initialize, #nilable, nilable, #non_nilable, noreturn, parse_node, parse_string, proc, #rbs_string, self_type, shape, simple, t_class, #to_s, tuple, type_parameter, untyped, void
Constructor Details
This class inherits a constructor from RBI::Type::Composite
Instance Method Details
#nilable? ⇒ Boolean
: -> bool
269 270 271 |
# File 'lib/rbi/type.rb', line 269 def nilable? @types.any? { |type| type.nilable? || (type.is_a?(Simple) && type.name == "NilClass") } end |
#to_rbi ⇒ Object
: -> String
264 265 266 |
# File 'lib/rbi/type.rb', line 264 def to_rbi "T.any(#{@types.map(&:to_rbi).join(", ")})" end |