Class: RVM::Functions::Map

Inherits:
Function show all
Defined in:
lib/rvm/functions/list/map.rb

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



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rvm/functions/list/map.rb', line 4

def Map.execute params, env
	if params.length == 2
		block = params[1]
		i = 0
		RVM::Classes[:list].new(params[0].map do |e|
			e = block.call([e, RVM::Classes[:number].new(i)], env)
			i += 1
			e # needed to assure that the right value is returned
		end,params[0].sepperator)
	else
		RVM::Classes[:error].new(1,"FUNCTION (#{self.class.to_s}) EXPECTS 2 ARGUMENTS BUT GOT #{params.length}")
	end
end

.signatureObject



18
19
20
# File 'lib/rvm/functions/list/map.rb', line 18

def Map.signature
	[:list, :block]
end