class Parlour::RbiGenerator
The RBI generator.
Constants
- Options
A set of immutable formatting options.
Attributes
root[R]
The root {Namespace} of this generator. @return [Namespace]
Public Class Methods
new(**hash)
click to toggle source
Calls superclass method
Parlour::Generator::new
# File lib/parlour/rbi_generator.rb, line 9 def initialize(**hash) super @root = RbiGenerator::Namespace.new(self) end
Public Instance Methods
rbi(strictness = 'strong')
click to toggle source
Returns the complete contents of the generated RBI file as a string.
@return [String] The generated RBI file
# File lib/parlour/rbi_generator.rb, line 23 def rbi(strictness = 'strong') # TODO: Early test option - convert to RBS if requested # Absolutely remove this later on if ENV['PARLOUR_CONVERT_TO_RBS'] # Perform conversion root.generalize_from_rbi! rbs_gen = Parlour::RbsGenerator.new converter = Parlour::Conversion::RbiToRbs.new(rbs_gen) root.children.each do |child| converter.convert_object(child, rbs_gen.root) end # Write the final RBS rbs_gen.rbs else "# typed: #{strictness}\n" + root.generate_rbi(0, options).join("\n") + "\n" end end