class Crygen::Types::Enum
- Crygen::Types::Enum
- Reference
- Object
Overview
A class that generates an enumeration (enum).
enum_type = Crygen::Types::Enum.new("Person")
enum_type.add_constant("Employee")
enum_type.add_constant("Student")
enum_type.add_constant("Intern")
puts enum_type.generate
Output:
enum Person
Employee
Student
Intern
end
Included Modules
Defined in:
types/enum.crConstructors
Instance Method Summary
-
#add_constant(name : String, value : String) : self
Adds a constant into enum (name and value).
-
#add_constant(name : String) : self
Adds a constant into enum (name only).
-
#generate : String
Generates an enum.
Instance methods inherited from module Crygen::Modules::Method
add_method(method : Crygen::Types::Method) : self
add_method
Constructor Detail
Instance Method Detail
def add_constant(name : String, value : String) : self
#
Adds a constant into enum (name and value).
enum_type = Crygen::Types::Enum.new("Person")
enum_type.add_constant("Employee", 1)
Returns: an object class itself.
def add_constant(name : String) : self
#
Adds a constant into enum (name only).
enum_type = Crygen::Types::Enum.new("Person")
enum_type.add_constant("Employee")
Output:
enum Person
Employee
end
Returns: an object class itself.