class
Crystal::Macros::ClassDef
Overview
A class definition.
Every class definitionnode is equivalent to:
{% begin %}
{% "abstract".id if node.abstract? %} {{ node.kind }} {{ node.name }} {% if superclass = node.superclass %}< {{ superclass }}{% end %}
{{ node.body }}
end
{% end %}
Defined in:
compiler/crystal/macros.crInstance Method Summary
-
#abstract? : BoolLiteral
Returns whether this node defines an abstract class or struct.
-
#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.
-
#struct? : BoolLiteral
Returns
trueif this node defines a struct,falseif this node defines a class. -
#superclass : ASTNode
Returns the superclass of this type definition, or a
Nopif one isn't specified. -
#type_vars : ArrayLiteral
Returns an array of
MacroIds 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
Returns the name of this type definition.
If this node defines a generic type, andgeneric_args is true, returns a
Generic whose type arguments areMacroIds, possibly with aSplat at
the splat index. Otherwise, this method returns aPath.
Returns the splat index of this type definition's generic type parameters.
Returnsnil if this type definition isn't generic or if there isn't a
splat parameter.
Returnstrue if this node defines a struct,false if this node defines
a class.
Returns an array ofMacroIds of this type definition's generic type
parameters.
On a non-generic type definition, returns an empty array.