Class: RBI::Type::Nilable

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

Overview

A type that can be ‘nil` like `T.nilable(String)`.

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) ⇒ Nilable

Returns a new instance of Nilable.



213
214
215
216
# File 'lib/rbi/type.rb', line 213

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



210
211
212
# File 'lib/rbi/type.rb', line 210

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



219
220
221
# File 'lib/rbi/type.rb', line 219

def ==(other)
  Nilable === other && @type == other.type
end

#to_rbiObject



224
225
226
# File 'lib/rbi/type.rb', line 224

def to_rbi
  "T.nilable(#{@type.to_rbi})"
end