Rscons::Varset: remove unused type parameter to #[]
This commit is contained in:
parent
7ff2ec1f1a
commit
e3aadc562f
@ -17,20 +17,8 @@ module Rscons
|
||||
|
||||
# Access the value of variable as a particular type
|
||||
# @param key [String, Symbol] The variable name.
|
||||
# @param type [Symbol, nil] Optional specification of the type desired.
|
||||
# If the variable is a String and type is :array, a 1-element array with
|
||||
# the variable value will be returned. If the variable is an Array and
|
||||
# type is :string, the first element from the variable value will be
|
||||
# returned.
|
||||
def [](key, type = nil)
|
||||
val = @vars[key]
|
||||
if type == :array and not val.is_a?(Array)
|
||||
[val]
|
||||
elsif type == :scalar and val.is_a?(Array)
|
||||
val.first
|
||||
else
|
||||
val
|
||||
end
|
||||
def [](key)
|
||||
@vars[key]
|
||||
end
|
||||
|
||||
# Assign a value to a variable.
|
||||
|
@ -30,12 +30,6 @@ module Rscons
|
||||
v["qax"].should == [3, 6]
|
||||
v["qux"].should == {a: :b}
|
||||
end
|
||||
it "allows accessing a non-array converted to an array" do
|
||||
v["fuz", :array].should == ["a string"]
|
||||
end
|
||||
it "allows accessing an array as a single value" do
|
||||
v["qax", :scalar].should == 3
|
||||
end
|
||||
end
|
||||
|
||||
describe :[]= do
|
||||
|
Loading…
x
Reference in New Issue
Block a user