Class: RBI::Type::ClassOf

Inherits:
RBI::Type show all
Defined in:
lib/rbi/type.rb

Overview

The singleton class of another type like ‘T.class_of(Foo)`.

Instance Attribute Summary collapse

Instance Method Summary collapse

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



286
287
288
289
290
# File 'lib/rbi/type.rb', line 286

def initialize(type, type_parameter = nil)
  super()
  @type = type
  @type_parameter = type_parameter
end

Instance Attribute Details

#typeObject (readonly)

: Simple



280
281
282
# File 'lib/rbi/type.rb', line 280

def type
  @type
end

#type_parameterObject (readonly)

: Type?



283
284
285
# File 'lib/rbi/type.rb', line 283

def type_parameter
  @type_parameter
end

Instance Method Details

#==(other) ⇒ Object

: (BasicObject other) -> bool



294
295
296
# File 'lib/rbi/type.rb', line 294

def ==(other)
  ClassOf === other && @type == other.type && @type_parameter == other.type_parameter
end

#normalizeObject

: -> Type



310
311
312
# File 'lib/rbi/type.rb', line 310

def normalize
  self
end

#simplifyObject

: -> Type



316
317
318
# File 'lib/rbi/type.rb', line 316

def simplify
  self
end

#to_rbiObject

: -> String



300
301
302
303
304
305
306
# File 'lib/rbi/type.rb', line 300

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