Agnus (agnus v0.1.1) View Source

Agnus is an Elixir supervised GenServer wrapping Sunrise Sunset

Link to this section Summary

Functions

Enable or disable caching of the JSON response from Sunrise Sunset

Is the data available for today?

Get the sun info keys available

Get noon

Get all or some sun information for today

Get sunrise

Get sunset

Trigger a refresh of the sun info for today

Trigger a refresh of the sun info for today

Link to this section Functions

Link to this function

cache_json(cache_file \\ :query)

View Source (since 0.1.1)

Specs

Enable or disable caching of the JSON response from Sunrise Sunset

Examples

iex> Agnus.cache_json("/tmp/agnus.json")
"/tmp/agnus.json"

iex> Agnus.cache_json(:none)
:none

iex> cf = Agnus.cache_json(:query)
iex> is_binary(cf) or cf == :none
true
Link to this function

current?()

View Source (since 0.0.3)

Specs

current?() :: true | false

Is the data available for today?

Examples

iex> Agnus.current?()
iex> true

Specs

keys() :: [Agnus.Types.suninfo_key()]

Get the sun info keys available

Examples

iex> keys = Agnus.keys()
iex> :sunrise in keys
true
iex> :sunset in keys
true
iex> Enum.count(keys)
11

Specs

noon() :: DateTime.t()

Get noon

Examples

iex> noon = Agnus.noon()
iex> DateTime.diff(noon, noon)
0
Link to this function

sun_info(term \\ :all)

View Source (since 0.0.3)

Specs

Get all or some sun information for today

Examples

iex> info = Agnus.sun_info(:all)
iex> is_map(info)
true

iex> info = Agnus.sun_info(:astronomical_twilight_begin)
iex> DateTime.diff(info, info)
0

iex> info = Agnus.sun_info(:astronomical_twilight_end)
iex> DateTime.diff(info, info)
0

iex> info = Agnus.sun_info(:day_length)
iex> is_integer(info)
true

iex> info = Agnus.sun_info([:astronomical_twilight_begin, :astronomical_twilight_end])
iex> is_map(info)
true
iex> Enum.count(info)
2

Specs

sunrise() :: DateTime.t()

Get sunrise

Examples

iex> sunrise = Agnus.sunrise()
iex> DateTime.diff(sunrise, sunrise)
0

Specs

sunset() :: DateTime.t()

Get sunset

Examples

iex> sunset = Agnus.sunset()
iex> DateTime.diff(sunset, sunset)
0
Link to this function

trigger_refresh(opts \\ [force: false])

View Source (since 0.1.1)

Trigger a refresh of the sun info for today

The most recent data is cached and, as such, repeated calls to this function on the same day are no ops.

Examples

iex> Agnus.trigger_refresh()
:ok

iex> Agnus.trigger_refresh(force: true)
:ok
Link to this function

trigger_sun_info_refresh(opts \\ [force: false])

View Source (since 0.0.3)
This function is deprecated. Use trigger_refresh/1 instead.

Specs

trigger_sun_info_refresh(Agnus.Types.trigger_opts()) :: :ok

Trigger a refresh of the sun info for today

The most recent data is cached and, as such, repeated calls to this function on the same day are no ops.

Examples

iex> Agnus.trigger_sun_info_refresh()
:ok

iex> Agnus.trigger_sun_info_refresh(force: true)
:ok