From 08702b7f217971c29581875c74e792e5cbe9567e Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 8 Dec 2017 10:21:14 -0800 Subject: Use integer for numeric evaluation Why is this not just in the duration calculator? Well we use it in two places and I would have had to add the same logic in both of those places. It's nice and easy to read this way Signed-off-by: Tim Smith --- lib/chef/resource/windows_task.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/chef/resource/windows_task.rb') diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index 7d7bd249a8..07674675bb 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -92,8 +92,9 @@ class Chef # Validate the passed value is numeric values only if it is a string def numeric_value_in_string?(val) - return false if val.is_a?(String) && /\D/ =~ val # \D is any non-numeric value - true + return true if Integer(val) + rescue ArgumentError + false end def validate_random_delay(random_delay, frequency) -- cgit v1.2.1