how exactly this cron parser is working here? #82
-
I have tried to import Crontab.CronExpression Then in iex shell I used this command to parse the corn expression Crontab.CronExpression.Parser.parse ("* * * * MON-TUE") But this giving me this output {:ok, ~e[* * * * 1-2 *]} Crontab.CronExpression.Parser.parse "* * * * *"
{:ok,
%Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
month: [:*], weekday: [:*], year: [:*]}} How this example is working? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is using a feature called Basically When using inspect, there is a custom protocol that also displays it as a sigil, since it is better to read than the |
Beta Was this translation helpful? Give feedback.
This is using a feature called
sigils
. You can find details about it here: https://elixir-lang.org/getting-started/sigils.htmlBasically
crontab
is registering a sigil when you import it: https://github.com/jshmrtn/crontab/blob/f42a90a1ab227c9137bd9f31d33ccfb1a82439e2/lib/crontab/cron_expression.ex#L140When using inspect, there is a custom protocol that also displays it as a sigil, since it is better to read than the
Crontab.CronExpression
struct.: https://github.com/jshmrtn/crontab/blob/f42a90a1ab227c9137bd9f31d33ccfb1a82439e2/lib/crontab/cron_expression.ex#L186