Class: RubyDetective::SourceRepresentation::Entities::Constant
- Defined in:
- lib/ruby_detective/source_representation/entities/constant.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#caller ⇒ Object
readonly
Returns the value of attribute caller.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#refers_to ⇒ Object
readonly
Returns the value of attribute refers_to.
Instance Method Summary collapse
- #caller_namespace ⇒ Object
-
#initialize(name, namespace, file_path:, caller:, refers_to: nil) ⇒ Constant
constructor
A new instance of Constant.
- #possible_paths_of_referenced_entity ⇒ Object
- #register_referred_class(klass) ⇒ Object
Methods inherited from Base
#absolute_path?, #namespace_as_text, #namespace_without_root_sign, #path, #path_as_text, #path_without_root_sign
Constructor Details
#initialize(name, namespace, file_path:, caller:, refers_to: nil) ⇒ Constant
Returns a new instance of Constant.
7 8 9 10 11 12 13 14 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 7 def initialize(name, namespace, file_path:, caller:, refers_to: nil) @name = name @namespace = namespace @file_path = file_path @refers_to = refers_to @caller = caller @data_store = SourceRepresentation::DataStore.instance end |
Instance Attribute Details
#caller ⇒ Object (readonly)
Returns the value of attribute caller.
5 6 7 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 5 def caller @caller end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
5 6 7 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 5 def file_path @file_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 5 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 5 def namespace @namespace end |
#refers_to ⇒ Object (readonly)
Returns the value of attribute refers_to.
5 6 7 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 5 def refers_to @refers_to end |
Instance Method Details
#caller_namespace ⇒ Object
16 17 18 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 16 def caller_namespace caller.namespace end |
#possible_paths_of_referenced_entity ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 24 def possible_paths_of_referenced_entity # If the constant was like "::Foo::Bar" there is only one possible # match: the exact path described in the constant return [path_without_root_sign] if absolute_path? possible_parent_namespaces .map { |possible_parent| possible_parent + path } .push(path) end |
#register_referred_class(klass) ⇒ Object
20 21 22 |
# File 'lib/ruby_detective/source_representation/entities/constant.rb', line 20 def register_referred_class(klass) @refers_to = klass end |