4 # Interface to process environment variables.
6 class EnvironmentVariables
11 env_get(StringValue(key))
15 env_set(StringValue(key), value.nil? ? nil : StringValue(value))
17 alias_method :store, :[]=
20 env_set(StringValue(key), nil)
25 raise ArgumentError, "wrong number of arguments (0 for 1)"
27 raise ArgumentError, "wrong number of arguments (#{params.size} for 2)"
29 if block_given? and params.size == 2
30 warn "block supersedes default value argument"
32 value = self[params[0]]
34 return yield(params[0]) if block_given?
35 raise IndexError, "key not found" if params.size == 1
42 alias_method :has_key?, :include?
43 alias_method :key?, :include?
44 # More efficient than using the one from Enumerable
45 alias_method :member?, :include?
56 to_hash.each { |k, v| yield k, v }
59 alias_method :each_pair, :each
73 to_hash.reject(&block)
86 each { |k, v| yield k }
90 each { |k, v| yield v }
94 to_hash.has_value? value
96 alias_method :value?, :has_value?
98 def values_at(*params)
99 to_hash.values_at(*params)
121 alias_method :size, :length
124 # No need to do anything, our keys are always strings
129 other.each { |k, v| self[k] = v }
134 return nil if hash.empty?
146 def update(other, &block)
148 other.each { |k, v| self[k] = yield k, self[k], v }
150 other.each { |k, v| self[k] = v }
154 # Missing and deprecated: index, indexes, indices