diff --git a/src/ytdl_sub/script/functions/boolean_functions.py b/src/ytdl_sub/script/functions/boolean_functions.py new file mode 100644 index 00000000..51cf5fb8 --- /dev/null +++ b/src/ytdl_sub/script/functions/boolean_functions.py @@ -0,0 +1,44 @@ +from ytdl_sub.script.types.resolvable import Boolean +from ytdl_sub.script.types.resolvable import Resolvable + + +class BooleanFunctions: + @staticmethod + def bool(value: Resolvable) -> Boolean: + return Boolean(bool(value.value)) + + @staticmethod + def equals(left: Resolvable, right: Resolvable) -> Boolean: + return Boolean(left.value == right.value) + + @staticmethod + def lt(left: Resolvable, right: Resolvable) -> Boolean: + return Boolean(left.value < right.value) + + @staticmethod + def lte(left: Resolvable, right: Resolvable) -> Boolean: + return Boolean(left.value <= right.value) + + @staticmethod + def gt(left: Resolvable, right: Resolvable) -> Boolean: + return Boolean(left.value > right.value) + + @staticmethod + def gte(left: Resolvable, right: Resolvable) -> Boolean: + return Boolean(left.value >= right.value) + + @staticmethod + def and_(left: Boolean, right: Boolean) -> Boolean: + return Boolean(left.value and right.value) + + @staticmethod + def or_(left: Boolean, right: Boolean) -> Boolean: + return Boolean(left.value or right.value) + + @staticmethod + def xor(left: Boolean, right: Boolean) -> Boolean: + return Boolean(left.value ^ right.value) + + @staticmethod + def not_(value: Boolean) -> Boolean: + return Boolean(not value.value) diff --git a/src/ytdl_sub/script/functions/numeric_functions.py b/src/ytdl_sub/script/functions/numeric_functions.py index beee8c25..2ded52da 100644 --- a/src/ytdl_sub/script/functions/numeric_functions.py +++ b/src/ytdl_sub/script/functions/numeric_functions.py @@ -38,3 +38,11 @@ class NumericFunctions: @staticmethod def mod(value: Integer, modulo: Integer) -> Integer: return Integer(value=value.value % modulo.value) + + @staticmethod + def max(left: Numeric, right: Numeric) -> Numeric: + return _to_numeric(max(left.value, right.value)) + + @staticmethod + def min(left: Numeric, right: Numeric) -> Numeric: + return _to_numeric(min(left.value, right.value))