Class: Steep::Index::SourceIndex::ConstantEntry
- Defined in:
- lib/steep/index/source_index.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#references ⇒ Object
readonly
Returns the value of attribute references.
Instance Method Summary collapse
- #add_definition(node) ⇒ Object
- #add_reference(node) ⇒ Object
-
#initialize(name:) ⇒ ConstantEntry
constructor
A new instance of ConstantEntry.
- #merge!(other) ⇒ Object
Constructor Details
#initialize(name:) ⇒ ConstantEntry
Returns a new instance of ConstantEntry.
10 11 12 13 14 15 |
# File 'lib/steep/index/source_index.rb', line 10 def initialize(name:) @name = name @definitions = Set[].compare_by_identity @references = Set[].compare_by_identity end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
7 8 9 |
# File 'lib/steep/index/source_index.rb', line 7 def definitions @definitions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/steep/index/source_index.rb', line 5 def name @name end |
#references ⇒ Object (readonly)
Returns the value of attribute references.
8 9 10 |
# File 'lib/steep/index/source_index.rb', line 8 def references @references end |
Instance Method Details
#add_definition(node) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/steep/index/source_index.rb', line 17 def add_definition(node) case node.type when :casgn, :const @definitions << node else raise "Unexpected constant definition: #{node.type}" end self end |
#add_reference(node) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/steep/index/source_index.rb', line 28 def add_reference(node) case node.type when :const @references << node else raise "Unexpected constant reference: #{node.type}" end self end |
#merge!(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/steep/index/source_index.rb', line 39 def merge!(other) definitions.merge(other.definitions) references.merge(other.references) self end |