View Source WeatherForecast (Vela v1.1.0)

The example of Vela implementation, demontrating the real-life module using Vela for timeseries control.

The full code of this file follows.

defmodule WeatherForecast do
  alias WeatherForecast, as: Me
  use Vela,
    __globals__: [validator: Me],
    tomorrow: [limit: 5, errors: 1],
    two_days: [limit: 3],
    week: [limit: 2, sorter: &Me.sort/2]

  @behaviour Vela.Validator

  @impl Vela.Validator
  def valid?(_serie, value), do: value > 0

  @doc "Sort function to be used as `:sorter` in series"
  def sort(v1, v2), do: v1 <= v2
end

Summary

Types

The possibly type of members of the result of call to Vela.slice/1

The result of call to Vela.slice/1

t()

The type of this particular Vela implementation

Functions

Empties the Vela given as an argument, preserving all the internal information (__meta__, __errors__ etc.)

Returns true if there are no values in all series, false otherwise. More performant implementation of slice(vela) == [].

Implementation of Vela.equal?/2.

Merges two Velas, using resolver/3 given as the third argument in a case of ambiguity.

Returns the list of series declared on WeatherForecast

Implementation of Vela.slice/1.

Sort function to be used as :sorter in series

Returns the initial state of WeatherForecast, custom options etc

Updates the internal state of WeatherForecast

Returns the config WeatherForecast was declared with

Types

@type serie_slice() ::
  {:tomorrow, [Vela.value()]}
  | {:two_days, [Vela.value()]}
  | {:week, [Vela.value()]}

The possibly type of members of the result of call to Vela.slice/1

@type slice() :: [serie_slice()]

The result of call to Vela.slice/1

@type t() :: %WeatherForecast{
  __errors__: [Vela.kv()],
  __meta__: Access.t(),
  tomorrow: [Vela.value()],
  two_days: [Vela.value()],
  week: [Vela.value()]
}

The type of this particular Vela implementation

Functions

Implementation of Vela.average/2.

Returns a slice of all series as keyword() in format {Vela.serie(), Vela.value()}, when the value is a calculated average of all serie values.

The second parameter might be either a function of arity 1, accepting a serie (a list of values), or a module, exporting average/1 function.

The result is similar to what slice/1 returns, but with average values.

Link to this function

delta(vela, comparator \\ nil)

View Source

Implementation of Vela.delta/2.

Delegates to Vela.δ/2.

Empties the Vela given as an argument, preserving all the internal information (__meta__, __errors__ etc.)

See: Vela.empty!/1.

Returns true if there are no values in all series, false otherwise. More performant implementation of slice(vela) == [].

See: Vela.empty?/1.

Implementation of Vela.equal?/2.

Delegates to Vela.equal?/2.

Merges two Velas, using resolver/3 given as the third argument in a case of ambiguity.

See: Vela.merge/3.

Link to this function

purge(vela, validator \\ nil)

View Source

Implementation of Vela.purge/2.

Purges values which are not passing validator given as a second parameter.

Returns the list of series declared on WeatherForecast

Implementation of Vela.slice/1.

Returns a slice of all series as keyword() in format {Vela.serie(), Vela.value()}, if the series has no values, it’s not included into result.

Sort function to be used as :sorter in series

@spec state(Vela.t()) :: Vela.state()

Returns the initial state of WeatherForecast, custom options etc

@spec update_state(Vela.t(), (Vela.state() -> Vela.state())) :: Vela.t()

Updates the internal state of WeatherForecast

@spec vela_config() :: [{atom(), Vela.options()}]

Returns the config WeatherForecast was declared with