Skip to content

Alias

Crygen provides a class to generate an alias. To do this, use Crygen::Types::Alias (here abbreviated as CGT::Alias).

This class takes 2 parameters: the alias name and an array of strings which are types name.

puts CGT::Alias.new("MyAlias", %w[Foo Bar])

Output:

alias MyAlias = Foo | Bar

Included modules

  • Crygen::Modules::Comment

Add a comment on an alias

In addition of creating an alias, you can put a comment.

alias_type = CGT::Alias.new("MyAlias", %w[Foo Bar])
alias_type.add_comment(<<-STR)
For example, this is my alias.
STR

Output:

# For example, this is my alias.
alias MyAlias = Foo | Bar

Info

Using the heredoc is recommended if you want to write a multiline comment.