Class: RBI::Type::Nilable

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

: (Type type) -> void



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

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

Instance Attribute Details

#typeObject (readonly)

: Type



208
209
210
# File 'lib/rbi/type.rb', line 208

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object

: (BasicObject other) -> bool



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

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

#to_rbiObject

: -> String



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

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