The App.version()
helper provides a series of methods for checking and comparing the current Sonadier version.
Examples
App.version()
returns an App.Helpers.Versions.VersionNumber
object with comparison methods. The example methods below all return true
if the current version is "2.0".
App.version().equals("2.0");
App.version().before("3.0");
App.version().after("1.19.99");
App.version().before("2.0.1.5");
Creating Version Numbers
You can initialize VersionNumber
objects to version your own scripts. Versions must be numeric, so names like "0.1a" will not work with these helpers.
var v = new App.Helpers.Versions.VersionNumber("1.0");
v.array() == [1, 0];
array()
Returns the version number, split by periods, and parsed into numbers.
App.version().array() == [2, 0];
after(other)
Checks whether the version is after another version. The other
parameter can be either a String
or VersionNumber
object.
App.version().after("1.95");
before(other)
Checks whether the version is before another version. The other
parameter can be either a String
or VersionNumber
object.
App.version().before("2.1");
equals(other)
Checks whether the version is directly equivalent to another version. The other
parameter can be either a String
or VersionNumber
object.
App.version().equals("2.0");