Class: RBI::Type::ClassOf
- Inherits:
-
Type
- Object
- Type
- RBI::Type::ClassOf
- Defined in:
- lib/rbi/type.rb
Overview
The singleton class of another type like T.class_of(Foo).
Instance Attribute Summary collapse
- #type ⇒ Object readonly
- #type_parameters ⇒ Object readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, *type_parameters) ⇒ ClassOf
constructor
A new instance of ClassOf.
- #normalize ⇒ Object
- #simplify ⇒ Object
- #to_rbi ⇒ Object
Constructor Details
#initialize(type, *type_parameters) ⇒ ClassOf
Returns a new instance of ClassOf.
322 323 324 325 326 |
# File 'lib/rbi/type.rb', line 322 def initialize(type, *type_parameters) super() @type = type @type_parameters = type_parameters #: Array[Type] end |
Instance Attribute Details
#type ⇒ Object (readonly)
316 317 318 |
# File 'lib/rbi/type.rb', line 316 def type @type end |
#type_parameters ⇒ Object (readonly)
319 320 321 |
# File 'lib/rbi/type.rb', line 319 def type_parameters @type_parameters end |
Instance Method Details
#==(other) ⇒ Object
330 331 332 |
# File 'lib/rbi/type.rb', line 330 def ==(other) ClassOf === other && @type == other.type && @type_parameters == other.type_parameters end |
#normalize ⇒ Object
346 347 348 |
# File 'lib/rbi/type.rb', line 346 def normalize self end |
#simplify ⇒ Object
352 353 354 |
# File 'lib/rbi/type.rb', line 352 def simplify self end |
#to_rbi ⇒ Object
336 337 338 339 340 341 342 |
# File 'lib/rbi/type.rb', line 336 def to_rbi if @type_parameters.empty? "::T.class_of(#{@type.to_rbi})" else "::T.class_of(#{@type.to_rbi})[#{@type_parameters.map(&:to_rbi).join(", ")}]" end end |