4.10. kink/ENUM_GROUP¶
Generation of enum values.
Example:
:ENUM_GROUP.require_from('kink/')
:Eg <- ENUM_GROUP.new('FILE_TYPE')
Eg.register(:file)
Eg.register(:directory)
Eg.register(:symbolic_link)
stdout.print_line(file.repr) # => FILE_TYPE.file
stdout.print_line((file == file).repr) # => true
stdout.print_line((file == directory).repr) # => false
4.10.1. type enum_group¶
An `enum_group` is a generator of a set of enum values.
4.10.1.1. Enum_group.new_member(Name)¶
`new_member` returns a new enum value of the enum group. `Name` is used as the name of the enum value.
The result enum value provides the following methods:
• M.op_eq(Arg): returns whether `M` and `Arg` are the same enum value. `Arg` must be a member of the same enum group as one of `M`.
• M.repr: returns a str like in the format of '{group name}.{enum name}', like 'PROTOCOL_FAMILY.ipv6'.
Precondition
• `Name` must be a str.
4.10.1.2. Enum_group.register(Varref)¶
`register` makes a new enum value, and sets a constant fun which returns the enum value to `Varref`.
Precondition
• `Varref` must be a varref.
4.10.1.3. Enum_group.name¶
`name` returns the name of the enum group.
4.10.1.4. Enum_group.all¶
`all` returns all the enum values of the enum group, in the order that the members were created.
4.10.1.5. Enum_group.have?(Val)¶
`have?` returns whether `Val` is a member of the enum group.
4.10.2. ENUM_GROUP.new(Name)¶
`new` makes a new `enum_group`.
`Name` is used as the name of the enum group.
Precondition
• `Name` must be a str.