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
Specs
cache_json(Agnus.Types.cache_file()) :: Agnus.Types.cache_file()
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
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
Specs
sun_info(Agnus.Types.suninfo_request()) :: Agnus.Types.suninfo_response()
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
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
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