Skip to content

Commit

Permalink
Better Type Declarations (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Jan 20, 2017
1 parent 6565de8 commit f3a7d0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/crontab/cron_expression.ex
Expand Up @@ -5,8 +5,17 @@ defmodule Crontab.CronExpression do

alias Crontab.CronExpression.Parser

@type t :: %Crontab.CronExpression{}
@type interval :: :minute | :hour | :day | :month | :weekday | :year
@type t :: %Crontab.CronExpression{
extended: boolean,
second: value,
minute: value,
hour: value,
day: value,
month: value,
weekday: value,
year: value
}
@type interval :: :second | :minute | :hour | :day | :month | :weekday | :year
@type min_max :: {:-, time_unit, time_unit}
@type value :: time_unit | :* | :L | {:L, value} | {:/, time_unit | :*
| min_max, pos_integer} | min_max | {:W, time_unit | :L}
Expand Down
1 change: 1 addition & 0 deletions lib/crontab/cron_expression/parser.ex
Expand Up @@ -122,6 +122,7 @@ defmodule Crontab.CronExpression.Parser do
end
defp interpret([], _, cron_expression), do: {:ok, cron_expression}
defp interpret(_, [], _), do: {:error, "The Cron Format String contains to many parts."}

@spec interpret(CronExpression.interval, binary) :: {:ok, [CronExpression.value]} | {:error, binary}
defp interpret(interval, format) do
parts = String.split(format, ",")
Expand Down

0 comments on commit f3a7d0a

Please sign in to comment.