Class: SupportTableData::Documentation::RbsDoc
- Inherits:
-
Object
- Object
- SupportTableData::Documentation::RbsDoc
- Defined in:
- lib/support_table_data/documentation/rbs_doc.rb
Overview
Generates RBS type signatures for the dynamically-defined named instance helper methods on a support table model.
Instance Method Summary collapse
-
#initialize(klass) ⇒ RbsDoc
constructor
A new instance of RbsDoc.
-
#signatures ⇒ String?
Render the full RBS file content for the model, including the class declaration.
Constructor Details
#initialize(klass) ⇒ RbsDoc
Returns a new instance of RbsDoc.
9 10 11 |
# File 'lib/support_table_data/documentation/rbs_doc.rb', line 9 def initialize(klass) @klass = klass end |
Instance Method Details
#signatures ⇒ String?
Render the full RBS file content for the model, including the class declaration. Returns nil when the model has no named instances.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/support_table_data/documentation/rbs_doc.rb', line 17 def signatures instance_names = klass.instance_names return nil if instance_names.empty? body_lines = [] instance_names.sort.each_with_index do |name, idx| body_lines << "" unless idx.zero? body_lines.concat(instance_signatures(name)) end <<~RBS # Generated by support_table_data - do not edit by hand. # To update, run `bundle exec rake support_table_data:rbs`. class #{klass.name} #{body_lines.map { |line| line.empty? ? "" : " #{line}" }.join("\n")} end RBS end |