Class: RBI::Type::ClassOf

Inherits:
RBI::Type show all
Extended by:
T::Sig
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

Returns a new instance of ClassOf.



184
185
186
187
188
# File 'lib/rbi/type.rb', line 184

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



178
179
180
# File 'lib/rbi/type.rb', line 178

def type
  @type
end

#type_parameterObject (readonly)

Returns the value of attribute type_parameter.



181
182
183
# File 'lib/rbi/type.rb', line 181

def type_parameter
  @type_parameter
end

Instance Method Details

#==(other) ⇒ Object



191
192
193
# File 'lib/rbi/type.rb', line 191

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

#to_rbiObject



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