Class: RubyLsp::TypeInferrer::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_lsp/type_inferrer.rb

Overview

A known type

Direct Known Subclasses

GuessedType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Type

: (String name) -> void



173
174
175
# File 'lib/ruby_lsp/type_inferrer.rb', line 173

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

: String



170
171
172
# File 'lib/ruby_lsp/type_inferrer.rb', line 170

def name
  @name
end

Instance Method Details

#attachedObject

Returns the attached version of this type by removing the ‘<Class:…>` part from its name : -> Type



179
180
181
182
183
184
# File 'lib/ruby_lsp/type_inferrer.rb', line 179

def attached
  Type.new(
    @name.split("::")[..-2] #: as !nil
    .join("::"),
  )
end