# class Crystal::Macros::ModuleDef

- Crystal::Macros::ModuleDef
- Crystal::Macros::ASTNode

##
Overview

A module definition.

Every module definition `node` is equivalent to:

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

##
Defined in:

compiler/crystal/macros.cr

##
Instance Method Summary

- #body : ASTNode

  Returns the body of this type definition.

- #kind : MacroId

  Returns the keyword used to define this type.

- #name(*, generic_args : BoolLiteral = true) : Path | Generic

  Returns the name of this type definition.

- #splat_index : NumberLiteral | NilLiteral

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

- #type_vars : ArrayLiteral

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

### 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.

def kind : MacroId #

Returns the keyword used to define this type.

For `ModuleDef` this is always `module`.

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 `MacroId`s, possibly with a `Splat` at the splat index. Otherwise, this method returns a `Path`.

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.

def type_vars : ArrayLiteral #

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

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