From c869e4fc9a30c9a54c1f9542ff160e5921d0881a Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 22 Mar 2019 20:12:36 -0600 Subject: [PATCH] Add to_s methods for result types --- src/spectator/errored_result.cr | 5 +++++ src/spectator/failed_result.cr | 5 +++++ src/spectator/pending_result.cr | 5 +++++ src/spectator/successful_result.cr | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/src/spectator/errored_result.cr b/src/spectator/errored_result.cr index fd06e67..b65e67e 100644 --- a/src/spectator/errored_result.cr +++ b/src/spectator/errored_result.cr @@ -17,5 +17,10 @@ module Spectator value = yield self interface.error(value) end + + # One-word descriptor of the result. + def to_s(io) + io << "error" + end end end diff --git a/src/spectator/failed_result.cr b/src/spectator/failed_result.cr index 7364c62..773778a 100644 --- a/src/spectator/failed_result.cr +++ b/src/spectator/failed_result.cr @@ -27,5 +27,10 @@ module Spectator value = yield self interface.failure(value) end + + # One-word descriptor of the result. + def to_s(io) + io << "fail" + end end end diff --git a/src/spectator/pending_result.cr b/src/spectator/pending_result.cr index 7e930c5..65512e9 100644 --- a/src/spectator/pending_result.cr +++ b/src/spectator/pending_result.cr @@ -16,5 +16,10 @@ module Spectator value = yield self interface.pending(value) end + + # One-word descriptor of the result. + def to_s(io) + io << "pending" + end end end diff --git a/src/spectator/successful_result.cr b/src/spectator/successful_result.cr index f590812..bd3f0ed 100644 --- a/src/spectator/successful_result.cr +++ b/src/spectator/successful_result.cr @@ -14,5 +14,10 @@ module Spectator value = yield self interface.success(value) end + + # One-word descriptor of the result. + def to_s(io) + io << "success" + end end end