From 975f6b06c80fdff25c9f10126968ef268e9bd103 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 27 Jun 2013 21:19:13 -0400 Subject: [PATCH] Environment.[]() allows specifying the type of variable you want returned --- lib/rscons/environment.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 03f99d7..70eabe4 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -34,8 +34,15 @@ module Rscons end end - def [](key) - @variables[key] + def [](key, type = nil) + val = @variables[key] + if type == :array + val.is_a?(String) ? [val] : val + elsif type == :string + val.is_a?(Array) ? val.first : val + else + val + end end def []=(key, val)