Burgerlib Python
Loading...
Searching...
No Matches
burger.validators.EnumProperty Class Reference

Class to enforce string list in member variable. More...

Inheritance diagram for burger.validators.EnumProperty:
Collaboration diagram for burger.validators.EnumProperty:

Public Member Functions

 __init__ (self, name, enums)
 Initialize to default.
 __set__ (self, instance, value)
 Set the string value.
Public Member Functions inherited from burger.validators.Property
 __init__ (self, name)
 Initialize to default.
 __get__ (self, instance, owner=None)
 Return value.
 __set__ (self, instance, value)
 Set the string value.

Protected Attributes

 _enums = enums
 Enumeration dictionary.
Protected Attributes inherited from burger.validators.Property
 _name = name
 The real name of the class instance.

Detailed Description

Class to enforce string list in member variable.

Examples

j = (("a", "b", "c"), "d", "e", ["f", "g", "h"], "i")
"Inherit from (object) for Python 2.7"
>>> class foo(object):
"Init to 0"
x = EnumProperty(j, "a")
"Init to 0"
y = EnumProperty(j)
"Init to 4"
z = EnumProperty(j, "i")
"Create the class"
f = foo()
"Print 0"
print(f.x)
"Print 2"
f.x = "g"
print(f.x)
"Print 2"
f.x = "h"
print(f.x)

Constructor & Destructor Documentation

◆ __init__()

burger.validators.EnumProperty.__init__ ( self,
name,
enums )

Initialize to default.

Parameters
nameName of the instance storage index
enumslist of enumeration strings

Member Function Documentation

◆ __set__()

burger.validators.EnumProperty.__set__ ( self,
instance,
value )

Set the string value.

Parameters
instanceReference to object containing data
valueNone or value the can be converted to bool