From 9bfca4a2a5df087355328a818904fa702b5ca587 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Wed, 7 Dec 2011 12:33:50 +0200 Subject: [PATCH] Use cursing to expected types when loading config.json. A better style than checking for types of values. More Rubyish too. --- lib/jsduck/options.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/jsduck/options.rb b/lib/jsduck/options.rb index 14b5e330..c0906d64 100644 --- a/lib/jsduck/options.rb +++ b/lib/jsduck/options.rb @@ -405,20 +405,16 @@ module JsDuck json.each_pair do |key, value| if key == "--" # filenames - config += value.is_a?(Array) ? value : [value] + config += Array(value).map(&:to_s) elsif value == true # simple switch - config += [key] - elsif value.is_a?(String) - # option with parameter - config += [key, value] - elsif value.is_a?(Array) - # one option multiple times - value.each do |v| - config += [key, v] - end + config += [key.to_s] else - # ignore anything else + # An option with value or with multiple values. + # In the latter case, add the option multiple times. + Array(value).each do |v| + config += [key.to_s, v.to_s] + end end end config -- GitLab