From 8436715e59fbc795ae812ddf2252ddcf6ff36225 Mon Sep 17 00:00:00 2001 From: Terrance Koar Date: Fri, 5 Apr 2024 15:29:49 -0400 Subject: [PATCH] return Delayed::Priority from add/subtract, add #to_d --- lib/delayed/priority.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/delayed/priority.rb b/lib/delayed/priority.rb index 951f628..129a176 100644 --- a/lib/delayed/priority.rb +++ b/lib/delayed/priority.rb @@ -174,11 +174,17 @@ def <=>(other) end def -(other) - to_i - other.to_i + other = other.to_i if other.is_a?(self.class) + self.class.new(to_i - other) end def +(other) - to_i + other.to_i + other = other.to_i if other.is_a?(self.class) + self.class.new(to_i + other) + end + + def to_d + to_i.to_d end private