Class: Steep::Index::SourceIndex::MethodEntry
- 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:) ⇒ MethodEntry
constructor
A new instance of MethodEntry.
- #merge!(other) ⇒ Object
Constructor Details
#initialize(name:) ⇒ MethodEntry
Returns a new instance of MethodEntry.
52 53 54 55 56 57 |
# File 'lib/steep/index/source_index.rb', line 52 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.
49 50 51 |
# File 'lib/steep/index/source_index.rb', line 49 def definitions @definitions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
47 48 49 |
# File 'lib/steep/index/source_index.rb', line 47 def name @name end |
#references ⇒ Object (readonly)
Returns the value of attribute references.
50 51 52 |
# File 'lib/steep/index/source_index.rb', line 50 def references @references end |
Instance Method Details
#add_definition(node) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/steep/index/source_index.rb', line 59 def add_definition(node) case node.type when :def, :defs @definitions << node else raise "Unexpected method definition: #{node.type}" end self end |
#add_reference(node) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/steep/index/source_index.rb', line 70 def add_reference(node) case node.type when :send, :block @references << node else raise "Unexpected method reference: #{node.type}" end self end |
#merge!(other) ⇒ Object
81 82 83 84 85 |
# File 'lib/steep/index/source_index.rb', line 81 def merge!(other) definitions.merge(other.definitions) references.merge(other.references) self end |