Class: RBI::Type::Generic

Inherits:
RBI::Type show all
Extended by:
T::Sig
Defined in:
lib/rbi/type.rb

Overview

A generic type like ‘T::Array` or `T::Hash[Symbol, Integer]`.

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(name, *params) ⇒ Generic

Returns a new instance of Generic.



289
290
291
292
293
# File 'lib/rbi/type.rb', line 289

def initialize(name, *params)
  super()
  @name = name
  @params = T.let(params, T::Array[Type])
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

Instance Method Details

#==(other) ⇒ Object



296
297
298
# File 'lib/rbi/type.rb', line 296

def ==(other)
  Generic === other && @name == other.name && @params == other.params
end

#to_rbiObject



301
302
303
# File 'lib/rbi/type.rb', line 301

def to_rbi
  "#{@name}[#{@params.map(&:to_rbi).join(", ")}]"
end