10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/cloudrail_si/servicecode/commands/Size.rb', line 10
def execute(environment, parameters)
Helper.assert(parameters.length === 2 &&
Helper.is_var_address(parameters[0]) &&
Helper.is_var_address(parameters[1]))
target_var = parameters[0]
container = environment.get_variable(parameters[1])
size = -1
if (Helper.is_array(container) || Helper.is_string(container))
size = container.length
elsif (Helper.is_object(container))
size = container.keys.length
end
environment.set_variable(target_var, size)
end
|