class Crygen::Types::Annotation
Overview
A class that allows to generate an annotation.
class_type = CGT::Class.new("Person")
class_type.add_annotation(CGT::Annotation.new("Experimental"))
puts class_type.generate
Output:
@[Experimental]
class Person
end
Defined in:
types/annotation.crConstructors
Instance Method Summary
-
#add_arg(name : String, value : String) : self
Adds a name and value into the argument.
-
#add_arg(value : String) : self
Adds only a value into the argument.
-
#generate : String
Generates an annotation.
Instance methods inherited from class Crygen::Abstract::GeneratorInterface
generate : String
generate
Constructor Detail
Instance Method Detail
def add_arg(name : String, value : String) : self
#
Adds a name and value into the argument.
annotation_type = Crygen::Types::Annotation.new("MyAnnotation")
annotation_type.add_arg("full_name", "John Doe".dump)
Output:
@[MyAnnotation(full_name: "John Doe")]
Returns: an object class itself.
def add_arg(value : String) : self
#
Adds only a value into the argument.
annotation_type = Crygen::Types::Annotation.new("MyAnnotation")
annotation_type.add_arg("true")
Output:
@[MyAnnotation(true)]
Returns: an object class itself.