View Source Crontab.CronExpression.Parser (crontab v1.1.14)

Parse string like * * * * * * to a %Crontab.CronExpression{}.

Summary

Functions

Parse string like * * * * * * to a %CronExpression{}.

Parse string like * * * * * * to a %CronExpression{}.

Types

@type result() :: {:ok, Crontab.CronExpression.t()} | {:error, binary()}

Functions

Link to this function

parse(cron_expression, extended \\ false)

View Source
@spec parse(binary(), boolean()) :: result()

Parse string like * * * * * * to a %CronExpression{}.

Examples

iex> Crontab.CronExpression.Parser.parse "* * * * *"
{:ok,
  %Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*]}}

iex> Crontab.CronExpression.Parser.parse "* * * * *", true
{:ok,
  %Crontab.CronExpression{extended: true, day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*], second: [:*]}}

iex> Crontab.CronExpression.Parser.parse "fooo"
{:error, "Can't parse fooo as minute."}
Link to this function

parse!(cron_expression, extended \\ false)

View Source
@spec parse!(binary(), boolean()) :: Crontab.CronExpression.t() | no_return()

Parse string like * * * * * * to a %CronExpression{}.

Examples

iex> Crontab.CronExpression.Parser.parse! "* * * * *"
%Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*]}

iex> Crontab.CronExpression.Parser.parse! "* * * * *", true
%Crontab.CronExpression{extended: true, day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*], second: [:*]}

iex> Crontab.CronExpression.Parser.parse! "fooo"
** (RuntimeError) Can't parse fooo as minute.