diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
commit | 77e50caaf2ef81cd91075cf836fed0e75718ffb4 (patch) | |
tree | 53b7b411290b63192fc9e924a3b6b65cdf67e9d0 /debian/vendor-h2o/deps/mruby/mrblib/compar.rb | |
parent | Adding upstream version 1.8.3. (diff) | |
download | dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.tar.xz dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.zip |
Adding debian version 1.8.3-2.debian/1.8.3-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | debian/vendor-h2o/deps/mruby/mrblib/compar.rb | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/debian/vendor-h2o/deps/mruby/mrblib/compar.rb b/debian/vendor-h2o/deps/mruby/mrblib/compar.rb new file mode 100644 index 0000000..84b9625 --- /dev/null +++ b/debian/vendor-h2o/deps/mruby/mrblib/compar.rb @@ -0,0 +1,84 @@ +## +# Comparable +# +# ISO 15.3.3 +module Comparable + + ## + # Return true if +self+ is less + # than +other+. Otherwise return + # false. + # + # ISO 15.3.3.2.1 + def < other + cmp = self <=> other + if cmp.nil? + raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + end + cmp < 0 + end + + ## + # Return true if +self+ is less + # than or equal to +other+. + # Otherwise return false. + # + # ISO 15.3.3.2.2 + def <= other + cmp = self <=> other + if cmp.nil? + raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + end + cmp <= 0 + end + + ## + # Return true if +self+ is equal + # to +other+. Otherwise return + # false. + # + # ISO 15.3.3.2.3 + def == other + cmp = self <=> other + cmp == 0 + end + + ## + # Return true if +self+ is greater + # than +other+. Otherwise return + # false. + # + # ISO 15.3.3.2.4 + def > other + cmp = self <=> other + if cmp.nil? + raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + end + cmp > 0 + end + + ## + # Return true if +self+ is greater + # than or equal to +other+. + # Otherwise return false. + # + # ISO 15.3.3.2.5 + def >= other + cmp = self <=> other + if cmp.nil? + raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + end + cmp >= 0 + end + + ## + # Return true if +self+ is greater + # than or equal to +min+ and + # less than or equal to +max+. + # Otherwise return false. + # + # ISO 15.3.3.2.6 + def between?(min, max) + self >= min and self <= max + end +end |