Class: RVM::Functions::Set

Inherits:
Function show all
Defined in:
lib/rvm/functions/collection/set.rb

Constant Summary collapse

FUNCTION_MAP =
{
  RVM::Classes::List => RVM::Functions::SetAt,
  Classes::Association => RVM::Functions::AssocSet
}

Class Method Summary collapse

Methods inherited from Function

call, data_type, execargs, method_missing, method_missing_old_functions

Methods included from Plugin

#helper, #included, #plugin_host, #plugin_id, #register_for

Class Method Details

.execute(params, env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rvm/functions/collection/set.rb', line 11

def execute params, env
  if params.length == 2
    if fun = FUNCTION_MAP[params.first.class]
      fun.execute(params, env)
    else
      RVM::Classes[:error].new(1, "FUNCTION (#{self.class}) does not accept #{params.first.class}")
    end
  elsif params.length == 1 and (this = env.read_var_val(:self)).is_a?(RVM::Classes[:association]) 
    if fun = FUNCTION_MAP[this]
      fun.execute(params, env)
    else
      RVM::Classes[:error].new(1, "FUNCTION (#{self.class}) does not accept #{thiss.class}")
    end         
  else
    RVM::Classes[:error].new(1, "FUNCTION (#{self.class}) EXPECTS 2 or 1 ARGUMENTS BUT GOT #{params.length}")
  end
end

.signatureObject



29
30
31
# File 'lib/rvm/functions/collection/set.rb', line 29

def signature
  [:any]
end