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
: Simple.
-
#type_parameter ⇒ Object
readonly
: Type?.
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (BasicObject other) -> bool.
-
#initialize(type, type_parameter = nil) ⇒ ClassOf
constructor
: (Simple type, ?Type? type_parameter) -> void.
-
#normalize ⇒ Object
: -> Type.
-
#simplify ⇒ Object
: -> Type.
-
#to_rbi ⇒ Object
: -> String.
Constructor Details
#initialize(type, type_parameter = nil) ⇒ ClassOf
: (Simple type, ?Type? type_parameter) -> void
322 323 324 325 326 |
# File 'lib/rbi/type.rb', line 322 def initialize(type, type_parameter = nil) super() @type = type @type_parameter = type_parameter end |
Instance Attribute Details
#type ⇒ Object (readonly)
: Simple
316 317 318 |
# File 'lib/rbi/type.rb', line 316 def type @type end |
#type_parameter ⇒ Object (readonly)
: Type?
319 320 321 |
# File 'lib/rbi/type.rb', line 319 def type_parameter @type_parameter end |
Instance Method Details
#==(other) ⇒ Object
: (BasicObject other) -> bool
330 331 332 |
# File 'lib/rbi/type.rb', line 330 def ==(other) ClassOf === other && @type == other.type && @type_parameter == other.type_parameter end |
#normalize ⇒ Object
: -> Type
346 347 348 |
# File 'lib/rbi/type.rb', line 346 def normalize self end |
#simplify ⇒ Object
: -> Type
352 353 354 |
# File 'lib/rbi/type.rb', line 352 def simplify self end |
#to_rbi ⇒ Object
: -> String
336 337 338 339 340 341 342 |
# File 'lib/rbi/type.rb', line 336 def to_rbi if @type_parameter "::T.class_of(#{@type.to_rbi})[#{@type_parameter.to_rbi}]" else "::T.class_of(#{@type.to_rbi})" end end |