class Crystal::Macros::ModuleDef


A module definition.

Every module definition node is equivalent to:

{% begin %}
  {{ node.kind }} {{ }}
    {{ node.body }}
{% end %}

Defined in:


Instance Method Summary

Instance methods inherited from class Crystal::Macros::ASTNode

!=(other : ASTNode) : BoolLiteral !=, ==(other : ASTNode) : BoolLiteral ==, class_name : StringLiteral class_name, column_number : StringLiteral | NilLiteral column_number, doc : StringLiteral doc, doc_comment : MacroId doc_comment, end_column_number : StringLiteral | NilLiteral end_column_number, end_line_number : StringLiteral | NilLiteral end_line_number, filename : StringLiteral | NilLiteral filename, id : MacroId id, is_a?(type : TypeNode) : BoolLiteral is_a?, line_number : StringLiteral | NilLiteral line_number, nil? : BoolLiteral nil?, raise(message) : NoReturn raise, stringify : StringLiteral stringify, symbolize : SymbolLiteral symbolize, warning(message : StringLiteral) : NilLiteral warning

Instance Method Detail

def body : ASTNode #

Returns the body of this type definition.

[View source]
def kind : MacroId #

Returns the keyword used to define this type.

For ModuleDef this is always module.

[View source]
def name(*, generic_args : BoolLiteral = true) : Path | Generic #

Returns the name of this type definition.

If this node defines a generic type, and generic_args is true, returns a Generic whose type arguments are MacroIds, possibly with a Splat at the splat index. Otherwise, this method returns a Path.

[View source]
def splat_index : NumberLiteral | NilLiteral #

Returns the splat index of this type definition's generic type parameters.

Returns nil if this type definition isn't generic or if there isn't a splat parameter.

[View source]
def type_vars : ArrayLiteral #

Returns an array of MacroIds of this type definition's generic type parameters.

On a non-generic type definition, returns an empty array.

[View source]