Class: RVM::Functions::AssocGet
- Defined in:
- lib/rvm/functions/association/assoc_get.rb
Overview
The AssocGet function is the Association (hash) equivalent to At function from the List. It get a Association as first argument and a index as the second. This index can be any kind of Class.
It can also be called with two arguments if :self is set as a variable and :self is a Association - in this case it is concidered a object function. The first passed parameter will be the key, the second the value.
Class Method Summary collapse
Methods inherited from Function
call, data_type, execargs, method_missing
Methods included from Plugin
#helper, #included, #plugin_host, #plugin_id, #register_for
Class Method Details
.execute(params, env) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rvm/functions/association/assoc_get.rb', line 39 def execute params, env if params.length == 2 assoc = params.shift key = params.shift assoc[key] elsif params.length == 1 and (this = env.read_var_val(:self)).is_a?(RVM::Classes[:association]) this[params.shift] else RVM::Classes[:error].new(1,"FUNCTION (#{self.class}) EXPECTS 2 or 1 ARGUMENTS BUT GOT #{params.length}") end end |
.signature ⇒ Object
51 52 53 |
# File 'lib/rvm/functions/association/assoc_get.rb', line 51 def signature [:any] end |