Class: Orthoses::ExcludeRBS
- Inherits:
-
Object
- Object
- Orthoses::ExcludeRBS
- Defined in:
- lib/orthoses/exclude_rbs.rb
Overview
Exclude RBS from output.
Instance Method Summary collapse
- #add_signature_to_known_env(rbs) ⇒ Object
- #call ⇒ Object
-
#initialize(loader, paths: nil, rbs: nil) ⇒ ExcludeRBS
constructor
A new instance of ExcludeRBS.
Constructor Details
#initialize(loader, paths: nil, rbs: nil) ⇒ ExcludeRBS
Returns a new instance of ExcludeRBS.
8 9 10 11 12 13 14 |
# File 'lib/orthoses/exclude_rbs.rb', line 8 def initialize(loader, paths: nil, rbs: nil) raise ArgumentError, ':paths or :rbs keyword is required' if paths.nil? && rbs.nil? @loader = loader @paths = paths @rbs = rbs end |
Instance Method Details
#add_signature_to_known_env(rbs) ⇒ Object
31 32 33 34 |
# File 'lib/orthoses/exclude_rbs.rb', line 31 def add_signature_to_known_env(rbs) buffer, directives, decls = ::RBS::Parser.parse_signature(rbs) Utils.rbs_environment.add_signature(buffer: buffer, directives: directives, decls: decls) end |
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/orthoses/exclude_rbs.rb', line 16 def call case when @paths @paths.each do |path| add_signature_to_known_env(File.read(path.to_s)) end when @rbs add_signature_to_known_env(@rbs) else raise "bug" end @loader.call end |