From ea5ff789f20c912852f7ffe30903fdc7f6747bd8 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 30 Jun 2013 19:30:22 -0400 Subject: [PATCH] add index function to Environment for variable access --- lib/rscons/environment.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 23c9c6d..86ffcb9 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -41,6 +41,21 @@ module Rscons @builders[builder_class.short_name] = builder_class end + def [](key, type = nil) + val = @variables[key] + if type == :array and val.is_a?(String) + [val] + elsif type == :string and val.is_a?(Array) + val.first + else + val + end + end + + def []=(key, val) + @variables[key] = val + end + def process end