class

Quartz::State

Inherits Reference / Object

A base class that wraps the state of a model. Automatically extended by models through use of the state macro.

See Stateful#state.

Constructors

Instance methods

==(other : self)

Returns true if this reference is the same as other. Invokes same?.

Source
==(other)

Returns false (other can only be a Value here).

Source
clone
Source
hash(hasher)

See Object#hash(hasher)

Source
inspect(io)
Source
to_hash
Source
to_json(json : JSON::Builder)
Source
to_named_tuple
Source

Macros

parameter(name, &block)

The parameter macro defines a state parameter for the State of a model.

It is intended to be used within a block provided with the Stateful#state macro.

Unlike state variables, parameters are read-only variables that can be set with the initial state of a model. As an example, they can be used to define the constants of an equation.

See also #var to declare state variables. See also Stateful#state.

Usage

parameter must receive a type declaration which will be used to declare an instance variable and a getter.

Default values must be declared using the type declaration notation or through a block (lazy initialization) :

state do
  parameter c = 0.013
end
Source
var(name, &block)

The var macro defines a state variable for the State of a model. Its primary goal is to generate convenient getters and setters for the model among other purposes.

It is intended to be used within a block provided with the Stateful#state macro.

Unlike state parameters, state variables are updated during the simulation by its model behaviour.

See also #parameter See also Stateful#state.

Usage

var must receive a type declaration which will be used to declare an instance variable, a getter and a setter.

Default values must be declared using the type declaration notation or through a block (lazy initialization) :

state do
  var foo : Int32 = 42
  var bar : Int32 { (rand * 100 + 1).to_i32 }
  var quz : Int32 { foo * 42 }
end

Note from previous example that the initialization block of quz is allowed to reference the value of another state variable.

Source