springroll.Enum Class

Defined in: springroll.Enum:62
Module: Core

An enumeration, similar to Enums in C#. Each value is created as an EnumValue on the Enum, referenced as a property with the same name as the EnumValue. Examples:

    var myEnum = new springroll.Enum(
        "valueOf0",
        "valueOf1",
        "valueOf2");
    var myOtherEnum = new springroll.Enum(
        {name: "one", value:"1", toString:"I am the One!"},
        "two",
        {name:"screwSequentialNumbers", value:42});
        
    myEnum.valueOf0 != 0;//enum values are not integers
    myEnum.valueOf1 != myOtherEnum.one;//enum values are not the same as other enums
    myEnum.valueOf2.asInt == 2;//enum values can be explicitly compared to integers
    myOtherEnum.screwSequentialNumbers == myOtherEnum.valueFromInt(42);//can use ints to get values
    console.log(myOtherEnum.one.toString());//outputs "I am the One!"

    for (var i in myEnum) console.log(i); //outputs "valueOf0","valueOf1","valueOf2"

Constructor

springroll.Enum

(
  • arguments The
)

Defined in springroll.Enum:62

Parameters:

  • arguments The Array | String | Object

    list of enumeration values. You can pass either an array or a list of parameters. Each string will be the previous value plus one, while objects with 'name' and 'value' properties will have the specified numeric value.

first

() EnumValue

Defined in first:210

Retrieves the first EnumValue in the Enum

Returns:

EnumValue:

last

() EnumValue

Defined in last:222

Retrieves the last EnumValue in the Enum

Returns:

EnumValue:

next

(
  • input
)
EnumValue

Defined in next:188

Retrieves the next EnumValue in the Enum (loops to first value at end).

Parameters:

  • input EnumValue

    An EnumValue to retrieve the value that follows.

Returns:

EnumValue:

valueFromInt

(
  • input
)
EnumValue

Defined in valueFromInt:237

Gets an enum value by integer value. If you have multiple enum values with the same integer value, this will always retrieve the first enum value.

Parameters:

  • input Int

    The integer value to get an enum value for.

Returns:

EnumValue:

The EnumValue that represents the input integer.

_byValue

Array private

Defined in _byValue:98

A potentially sparse array of each enum value, stored by integer values.

length

Int public

Defined in length:176

The count of values the enum was initialized with.

rawEnumValues

Array public

Defined in rawEnumValues:110

The values that this Enum was initialized with. We save this so that we can potentially pass this via Bellhop and re-initialize.