Class: Evilution::AST::SubjectFinder
- Inherits:
-
Prism::Visitor
- Object
- Prism::Visitor
- Evilution::AST::SubjectFinder
- Defined in:
- lib/evilution/ast/parser.rb
Instance Attribute Summary collapse
-
#subjects ⇒ Object
readonly
Returns the value of attribute subjects.
Instance Method Summary collapse
-
#initialize(source, file_path) ⇒ SubjectFinder
constructor
A new instance of SubjectFinder.
- #visit_class_node(node) ⇒ Object
- #visit_def_node(node) ⇒ Object
- #visit_module_node(node) ⇒ Object
Constructor Details
#initialize(source, file_path) ⇒ SubjectFinder
Returns a new instance of SubjectFinder.
37 38 39 40 41 42 |
# File 'lib/evilution/ast/parser.rb', line 37 def initialize(source, file_path) @source = source @file_path = file_path @subjects = [] @context = [] end |
Instance Attribute Details
#subjects ⇒ Object (readonly)
Returns the value of attribute subjects.
35 36 37 |
# File 'lib/evilution/ast/parser.rb', line 35 def subjects @subjects end |
Instance Method Details
#visit_class_node(node) ⇒ Object
50 51 52 53 54 |
# File 'lib/evilution/ast/parser.rb', line 50 def visit_class_node(node) @context.push(constant_name(node.constant_path)) super @context.pop end |
#visit_def_node(node) ⇒ Object
56 57 58 59 60 |
# File 'lib/evilution/ast/parser.rb', line 56 def visit_def_node(node) separator = node.receiver ? "." : "#" add_subject(node, separator) super end |
#visit_module_node(node) ⇒ Object
44 45 46 47 48 |
# File 'lib/evilution/ast/parser.rb', line 44 def visit_module_node(node) @context.push(constant_name(node.constant_path)) super @context.pop end |