From 0658dcf215129b1a309c719fced5e90803dfcf06 Mon Sep 17 00:00:00 2001 From: Tristan Ancelet Date: Tue, 8 Sep 2026 10:59:59 -0500 Subject: [PATCH] added convinent to_s method for RelativeOperation --- src/cligen/timeparse/relative_operation.cr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cligen/timeparse/relative_operation.cr b/src/cligen/timeparse/relative_operation.cr index bad733c..61c4edd 100644 --- a/src/cligen/timeparse/relative_operation.cr +++ b/src/cligen/timeparse/relative_operation.cr @@ -32,6 +32,14 @@ module CliGen::Timeparse raw.scan(CliGen::Regex::RELATIVE_OPERATION).map{|match| from_regex(match)} end + def to_s(io : IO) + io << to_s + end + + def to_s + "%s%d %s" % [ @sign == -1 ? "-" : "+", @quantity, @unit.to_s.downcase ] + end + # Just an initializer from a regex match. Only callable internally # so any operations must come from get_operations as that will handle # parsing it for the user