From 66e75b4315fdcc87d772e30bc3602ba7e7d28119 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 10 Oct 2020 21:39:00 +0600 Subject: [PATCH] add "each" --- CHANGELOG.md | 1 + .../com/insanusmokrassar/krontab/builder/TimeBuilder.kt | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f39ef..cc2ea33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### 0.3.2 +* Function `TimeBuilder#each` was added (works as `at`) * Add opportunity to use `first` shortcuts: * Value property `TimeBuilder#first` for including via functions like `TimeBuilder#at` * Shortcut for kron string format `f` or `F` diff --git a/src/commonMain/kotlin/com/insanusmokrassar/krontab/builder/TimeBuilder.kt b/src/commonMain/kotlin/com/insanusmokrassar/krontab/builder/TimeBuilder.kt index 75e87e2..467e48d 100644 --- a/src/commonMain/kotlin/com/insanusmokrassar/krontab/builder/TimeBuilder.kt +++ b/src/commonMain/kotlin/com/insanusmokrassar/krontab/builder/TimeBuilder.kt @@ -48,6 +48,13 @@ sealed class TimeBuilder ( result = (result ?: emptySet()) + value.clamp(restrictionsRange) } + + /** + * Shortcut for [at]. In fact will + */ + @Suppress("unused", "NOTHING_TO_INLINE") + inline infix fun each(value: Int) = at(value) + /** * Just wrapper for more obvious writing something like "[from] 2 [every] 5". For example, for [SecondsBuilder] it * will mean "[from] second second [every] 5 seconds", or "2, 7, 13, ..."