Update semver.er

This commit is contained in:
Shunsuke Shibayama 2023-10-16 11:40:02 +09:00
parent 9389ba3641
commit 55f24ae5a6

View file

@ -13,6 +13,8 @@
assert num_ in Nat
.Identifier::__new__ { .name; .num = num_ }
_ -> panic "invalid identifier string: \{s}"
@Override
__repr__ ref self = "Identifier(\{self.name}.\{self.num})"
.SemVer = Class { .major = Nat; .minor = Nat; .patch = Nat; .pre = .Identifier or NoneType }
.SemVer|<: Show|.
@ -30,6 +32,8 @@
[major, minor, patch, pre] ->
.SemVer.new(nat(major), nat(minor), nat(patch), .Identifier.from_str(pre))
_ -> panic "invalid semver string: \{s}"
@Override
__repr__ ref self = self.__str__()
#[
greater self, other: .Version =
match [self.major > other.major, self.major >= other.major, self.minor > other.minor, self.minor >= other.minor, self.patch > other.patch]: