Class: RBI::Type::Generic

Inherits:
RBI::Type show all
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

: (String name, *Type params) -> void



519
520
521
522
523
# File 'lib/rbi/type.rb', line 519

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

Instance Attribute Details

#nameObject (readonly)

: String



513
514
515
# File 'lib/rbi/type.rb', line 513

def name
  @name
end

#paramsObject (readonly)

: Array



516
517
518
# File 'lib/rbi/type.rb', line 516

def params
  @params
end

Instance Method Details

#==(other) ⇒ Object

: (BasicObject other) -> bool



527
528
529
# File 'lib/rbi/type.rb', line 527

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

#normalizeObject

: -> Type



539
540
541
# File 'lib/rbi/type.rb', line 539

def normalize
  self
end

#simplifyObject

: -> Type



545
546
547
# File 'lib/rbi/type.rb', line 545

def simplify
  self
end

#to_rbiObject

: -> String



533
534
535
# File 'lib/rbi/type.rb', line 533

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