summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-12-08 10:21:14 -0800
committerTim Smith <tsmith@chef.io>2017-12-08 10:21:14 -0800
commit08702b7f217971c29581875c74e792e5cbe9567e (patch)
tree7d17c27a87569808b412141b958c2461451e7a39
parent973d91ab278529dd859f32c7206deec6600f449c (diff)
downloadchef-08702b7f217971c29581875c74e792e5cbe9567e.tar.gz
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 <tsmith@chef.io>
-rw-r--r--lib/chef/resource/windows_task.rb5
1 files changed, 3 insertions, 2 deletions
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)