class Crygen::Types::Macro
- Crygen::Types::Macro
- Crygen::Abstract::GeneratorInterface
- Reference
- Object
Overview
A class that generates a macro
macro_type = CGT::Macro.new("example")
macro_type.add_arg("name")
puts macro_type.generate
Output:
macro example(name)
puts {{ name }}
end
Defined in:
types/macro.crConstructors
Instance Method Summary
-
#add_arg(arg : String) : self
Adds an argument to the macro.
-
#add_body(line : String) : self
Adds a new line into the macro body.
-
#body=(body : String) : self
Write the macro body.
-
#generate : String
Generates the macro.
Instance methods inherited from class Crygen::Abstract::GeneratorInterface
generate : String
generate
Constructor Detail
Instance Method Detail
def add_arg(arg : String) : self
#
Adds an argument to the macro.
macro_type = CGT::Macro.new("example")
macro_type.add_arg("name")
Output:
macro example(name)
end
Parameters:
- arg : String Returns: an object class itself.
def add_body(line : String) : self
#
Adds a new line into the macro body.
macro_type = CGT::Macro.new("example")
macro_type.add_arg("name")
macro_type.add_body("puts {{ name }}")
Output:
macro example(name)
puts {{ name }}
end
Parameters:
- line : String Returns: an object class itself.
def body=(body : String) : self
#
Write the macro body.
macro_type = CGT::Macro.new("example")
macro_type.add_arg("name")
macro_type.body = "puts {{ name }}"
Output:
macro example(name)
puts {{ name }}
end
Parameters:
- body : String Returns: an object class itself.