class
Crygen::Types::Method
- Crygen::Types::Method
- Crygen::Interfaces::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::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::Arg
add_arg(name : String, type : String, value : String | Nil = nil) : 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::Interfaces::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
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