System
gives access to some system primitives.
Static Methods
abort(reason)
Abort the current script, terminating with a runtime error. A reason
can be displayed.
if (0 == 1) {
System.abort("Weird!")
} else {
IO.println("OK") #> OK
}
clock
Return a Float
representing the processor time used by the script, in seconds. This measure is approximate, do not rely on it to make real benchmarks.
def now = System.clock
IO.println(now is Float) #> true
env(name)
Return the environment variable named name
, or nil
if the environment variable does not exist.
IO.println(System.env("NOT_A_VALID_NAME")) #> nil
time
Return an Int
representing the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
def now = System.time
IO.println(now is Int) #> true
version
Return the current version of Agate in an Array
form. The first element of the array is the major part of the version, the second element is the minor part of the version and the third element is the patch part of the version.
IO.println(System.version) #> [0, 1, 0]
version_string
Return the current version of Agate in a String
form.
IO.println(System.version_string) #> 0.1.0
IO.println(System.version_string.split('.')) #> [0, 1, 0]