class
Crygen::Types::Class
- Crygen::Types::Class
- Crygen::Interfaces::GeneratorInterface
- Reference
- Object
Overview
A class that generates a class.
class_person = CGT::Class.new("Person")
class_person.add_comment("This is a class called Person.")
class_person.add_method(method_full_name)
puts class_person.generate
Output:
# This is a class called Person.
class Person
# Gets the person's full name.
def full_name : String
"John Doe"
end
end
Included Modules
- Crygen::Modules::Annotation
- Crygen::Modules::ClassVar
- Crygen::Modules::Comment
- Crygen::Modules::InstanceVar
- Crygen::Modules::Method
- Crygen::Modules::Mixin
- Crygen::Modules::Property
Defined in:
types/class.crConstructors
Instance Method Summary
-
#as_abstract : self
Set as an abstract class.
-
#generate : String
Generates a Crystal code.
Instance methods inherited from module Crygen::Modules::Mixin
add_extend(name : String) : self
add_extend,
add_include(name : String) : self
add_include
Instance methods inherited from module Crygen::Modules::Annotation
add_annotation(annotation_type : Crygen::Types::Annotation) : self
add_annotation
Instance methods inherited from module Crygen::Helpers::Annotation
add_link(name : String) : self
add_link,
as_deprecated(message : String) : selfas_deprecated : self as_deprecated, as_experimental(message : String) : self
as_experimental : self as_experimental, as_flags : self as_flags
Instance methods inherited from module Crygen::Modules::Method
add_method(method : Crygen::Types::Method) : self
add_method
Instance methods inherited from module Crygen::Modules::ClassVar
add_class_var(name : String, type : String, value : String | Nil = nil) : self
add_class_var,
generate_class_vars : String
generate_class_vars
Instance methods inherited from module Crygen::Modules::InstanceVar
add_instance_var(name : String, type : String, value : String | Nil = nil) : self
add_instance_var,
generate_instance_vars : String
generate_instance_vars
Instance methods inherited from module Crygen::Modules::Property
add_property(visibility : Crygen::Enums::PropVisibility, name : String, type : String, *, value : String | Nil = nil, scope : Crygen::Enums::PropScope = :public, comment : String | Nil = nil) : self
add_property
Instance methods inherited from module Crygen::Modules::Comment
add_comment(value : String) : self
add_comment
Instance methods inherited from class Crygen::Interfaces::GeneratorInterface
generate : String
generate
Constructor Detail
Instance Method Detail
def as_abstract : self
#
Set as an abstract class.
class_type = CGT::Class.new("Person")
class_type.as_abstract
Output:
abstract class Person
end