class Crygen::Types::Method
- Crygen::Types::Method
- Crygen::Abstract::GeneratorInterface
- Reference
- Object
Overview
A class that generates a method.
method_type = CGT::Method.new("major?", "Bool")
method_type.add_arg("age", "Int8", "22")
method_type.add_body("Hello world".dump)
Output:
def major?(age : Int8 = 22) : Bool
"Hello world"
end
Included Modules
Defined in:
types/method.crConstructors
Instance Method Summary
-
#add_annotation(annotation_type : Crygen::Types::Annotation) : self
Adds an annotation on a class.
-
#add_body(body : String) : self
Add a code into method.
-
#generate : String
Generates the methods.
Instance methods inherited from module Crygen::Modules::Annotation
add_annotation(annotation_type : Crygen::Types::Annotation) : self
add_annotation
Instance methods inherited from module Crygen::Modules::Arg
add_arg(name : String, type : String, value : String) : selfadd_arg(name : String, type : String) : self add_arg, generate_args : String generate_args
Instance methods inherited from module Crygen::Modules::Scope
as_private : self
as_private,
as_protected : self
as_protected
Instance methods inherited from module Crygen::Modules::Comment
add_comment(value : String) : self
add_comment
Instance methods inherited from class Crygen::Abstract::GeneratorInterface
generate : String
generate
Constructor Detail
Instance Method Detail
Adds an annotation on a class.
method_type = CGT::Method.new("full_name", "String")
method_type.add_annotation(CGT::Annotation.new("Experimental"))
Output:
@[Experimental]
def full_name : String
end
Parameters:
- annotation_type : Crygen::Types::Annotation Returns: an object class itself.
def add_body(body : String) : self
#
Add a code into method.
method_type = CGT::Method.new("full_name", "String")
method_type.add_body("Hello world".dump)
Output:
def full_name : String
"Hello world"
end
Parameters:
- body : String Returns: an object class itself.