Class: SorbetErb::CodeExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/sorbet_erb/code_extractor.rb

Instance Method Summary collapse

Constructor Details

#initializeCodeExtractor

Returns a new instance of CodeExtractor.



8
# File 'lib/sorbet_erb/code_extractor.rb', line 8

def initialize; end

Instance Method Details

#extract(input) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/sorbet_erb/code_extractor.rb', line 10

def extract(input)
  buffer = Parser::Source::Buffer.new('(buffer)')
  buffer.source = input
  parser = BetterHtml::Parser.new(buffer)

  p = CodeProcessor.new
  p.process(parser.ast)
  [p.output, p.locals, p.locals_sig]
end