Class: Yard2rbs::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/yard2rbs/converter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_path) ⇒ void

Parameters:

  • input_path (String)


23
24
25
26
27
# File 'lib/yard2rbs/converter.rb', line 23

def initialize(input_path)
  @parse_result = Prism.parse_file(input_path)
  @parse_result.attach_comments!
  @output = []
end

Class Method Details

.convert(input_path) ⇒ String

Parameters:

  • input_path (String)

Returns:

  • (String)


16
17
18
# File 'lib/yard2rbs/converter.rb', line 16

def convert(input_path)
  new(input_path).convert
end

Instance Method Details

#convertString

Returns:

  • (String)


30
31
32
33
34
35
36
37
38
# File 'lib/yard2rbs/converter.rb', line 30

def convert
  @_indent_level = 0
  @_superclasses = []
  # puts @parse_result.value.inspect
  process(@parse_result.value)
  output = @output.join("\n")
  validate(output)
  output
end