Method: Parlour::RbsGenerator::Namespace#add_comment_to_next_child

Defined in:
lib/parlour/rbs_generator/namespace.rb

#add_comment_to_next_child(comment) ⇒ void

This method returns an undefined value.

Adds one or more comments to the next child RBS object to be created.

Examples:

Creating a module with a comment.

namespace.add_comment_to_next_child('This is a module')
namespace.create_module('M')

Creating a class with a multi-line comment.

namespace.add_comment_to_next_child(['This is a multi-line comment!', 'It can be as long as you want!'])
namespace.create_class('C')

Parameters:

  • comment (String, Array<String>)

    The new comment(s).



139
140
141
142
143
144
145
# File 'lib/parlour/rbs_generator/namespace.rb', line 139

def add_comment_to_next_child(comment)
  if comment.is_a?(String)
    @next_comments << comment
  elsif comment.is_a?(Array)
    @next_comments.concat(comment)
  end
end