Class: RBI::Type::Tuple

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

Overview

A tuple type like ‘[String, 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(types) ⇒ Tuple

: (Array types) -> void



336
337
338
339
# File 'lib/rbi/type.rb', line 336

def initialize(types)
  super()
  @types = types
end

Instance Attribute Details

#typesObject (readonly)

: Array



333
334
335
# File 'lib/rbi/type.rb', line 333

def types
  @types
end

Instance Method Details

#==(other) ⇒ Object

: (BasicObject other) -> bool



343
344
345
# File 'lib/rbi/type.rb', line 343

def ==(other)
  Tuple === other && @types == other.types
end

#to_rbiObject

: -> String



349
350
351
# File 'lib/rbi/type.rb', line 349

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