Class: RBI::Type::Any
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/type.rb
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
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
271 272 273 |
# File 'lib/rbi/type.rb', line 271 def nilable? @types.any? { |type| type.nilable? || (type.is_a?(Simple) && type.name == "NilClass") } end |
#to_rbi ⇒ Object
266 267 268 |
# File 'lib/rbi/type.rb', line 266 def to_rbi "T.any(#{@types.map(&:to_rbi).join(", ")})" end |