Class: Spoom::Model::Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/spoom/model/model.rb

Overview

A Symbol is a uniquely named entity in the Ruby codebase

A symbol can have multiple definitions, e.g. a class can be reopened. Sometimes a symbol can have multiple definitions of different types, e.g. ‘foo` method can be defined both as a method and as an attribute accessor.

Direct Known Subclasses

UnresolvedSymbol

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_name) ⇒ Symbol

: (String full_name) -> void



37
38
39
40
# File 'lib/spoom/model/model.rb', line 37

def initialize(full_name)
  @full_name = full_name
  @definitions = T.let([], T::Array[SymbolDef])
end

Instance Attribute Details

#definitionsObject (readonly)

The definitions of this symbol (where it exists in the code) : Array



34
35
36
# File 'lib/spoom/model/model.rb', line 34

def definitions
  @definitions
end

#full_nameObject (readonly)

The full, unique name of this symbol : String



30
31
32
# File 'lib/spoom/model/model.rb', line 30

def full_name
  @full_name
end

Instance Method Details

#nameObject

The short name of this symbol : -> String



44
45
46
# File 'lib/spoom/model/model.rb', line 44

def name
  T.must(@full_name.split("::").last)
end

#to_sObject

: -> String



49
50
51
# File 'lib/spoom/model/model.rb', line 49

def to_s
  @full_name
end