Class: RBI::Type::ClassOf
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.
-
#to_rbi ⇒ Object
: -> String.
Methods inherited from RBI::Type
all, any, anything, attached_class, boolean, class_of, #eql?, generic, #hash, #nilable, 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
#initialize(type, type_parameter = nil) ⇒ ClassOf
: (Simple type, ?Type? type_parameter) -> void
182 183 184 185 186 |
# File 'lib/rbi/type.rb', line 182 def initialize(type, type_parameter = nil) super() @type = type @type_parameter = type_parameter end |
Instance Attribute Details
#type ⇒ Object (readonly)
: Simple
176 177 178 |
# File 'lib/rbi/type.rb', line 176 def type @type end |
#type_parameter ⇒ Object (readonly)
: Type?
179 180 181 |
# File 'lib/rbi/type.rb', line 179 def type_parameter @type_parameter end |
Instance Method Details
#==(other) ⇒ Object
: (BasicObject other) -> bool
190 191 192 |
# File 'lib/rbi/type.rb', line 190 def ==(other) ClassOf === other && @type == other.type && @type_parameter == other.type_parameter end |
#to_rbi ⇒ Object
: -> String
196 197 198 199 200 201 202 |
# File 'lib/rbi/type.rb', line 196 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 |