Class: RBS::Inline::Annotator::Processor
- Inherits:
-
Object
- Object
- RBS::Inline::Annotator::Processor
- Defined in:
- lib/rbs/inline/annotator/processor.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(target:, env:) ⇒ Processor
constructor
A new instance of Processor.
- #process ⇒ Object
Constructor Details
#initialize(target:, env:) ⇒ Processor
Returns a new instance of Processor.
15 16 17 18 |
# File 'lib/rbs/inline/annotator/processor.rb', line 15 def initialize(target:, env:) @target = target @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
13 14 15 |
# File 'lib/rbs/inline/annotator/processor.rb', line 13 def env @env end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
13 14 15 |
# File 'lib/rbs/inline/annotator/processor.rb', line 13 def target @target end |
Instance Method Details
#process ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbs/inline/annotator/processor.rb', line 21 def process absolute_path = Pathname.pwd + target source = absolute_path.read writer = Writer.new(source) result = Result.new(writer:, prism_result: Prism.parse_file(absolute_path.to_s)) result.prism_result.value.accept(Visitor.new(env:, result:)) if result.writer.actions.empty? [source, false] else [writer.process, true] end end |