mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-23 02:28:52 +00:00
add "every" and "upTo" infix functions in time builder
This commit is contained in:
parent
b9bb7f3373
commit
b93b9fd7c7
@ -12,14 +12,6 @@ fun buildSchedule(settingsBlock: SchedulerBuilder.() -> Unit): CronDateTimeSched
|
|||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
//infix fun Int.withStep(step: Int): PropertyHolder {
|
|
||||||
// return DivPropertyHolder(this, step)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//operator fun Int.minus(including: Int): PropertyHolder {
|
|
||||||
// return RangePropertyHolder(this, including)
|
|
||||||
//}
|
|
||||||
|
|
||||||
class SchedulerBuilder(
|
class SchedulerBuilder(
|
||||||
private var seconds: Array<Byte>? = null,
|
private var seconds: Array<Byte>? = null,
|
||||||
private var minutes: Array<Byte>? = null,
|
private var minutes: Array<Byte>? = null,
|
||||||
|
@ -21,7 +21,7 @@ sealed class TimeBuilder (
|
|||||||
result = (result ?: emptySet()) + value.clamp(restrictionsRange)
|
result = (result ?: emptySet()) + value.clamp(restrictionsRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline infix fun from(value: Int) = value
|
inline fun from(value: Int) = value
|
||||||
|
|
||||||
infix fun Int.every(delay: Int): Array<Int> {
|
infix fun Int.every(delay: Int): Array<Int> {
|
||||||
val progression = clamp(restrictionsRange) .. restrictionsRange.last step delay
|
val progression = clamp(restrictionsRange) .. restrictionsRange.last step delay
|
||||||
@ -31,6 +31,7 @@ sealed class TimeBuilder (
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
infix fun every(delay: Int): Array<Int> = 0 every delay
|
||||||
|
|
||||||
infix fun Int.upTo(endIncluding: Int): Array<Int> {
|
infix fun Int.upTo(endIncluding: Int): Array<Int> {
|
||||||
val progression = clamp(restrictionsRange) .. endIncluding.clamp(restrictionsRange)
|
val progression = clamp(restrictionsRange) .. endIncluding.clamp(restrictionsRange)
|
||||||
@ -40,6 +41,7 @@ sealed class TimeBuilder (
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
infix fun upTo(endIncluding: Int): Array<Int> = 0 upTo endIncluding
|
||||||
|
|
||||||
internal fun build() = result ?.map { it.toByte() } ?.toTypedArray()
|
internal fun build() = result ?.map { it.toByte() } ?.toTypedArray()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user