Class: RVM::Functions::At

Inherits:
Function show all
Defined in:
lib/rvm/functions/array/at.rb

Overview

The At function is used to access elements for a List, it takes the List the get the element from as a first argument and the position to get it from, a Number, as the second.

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



33
34
35
36
37
38
39
40
41
# File 'lib/rvm/functions/array/at.rb', line 33

def execute params, env
  if params.length == 2
    array = params.shift
    pos = params.shift
    array[pos.to_i]
  else
    RVM::Classes[:error].new(1,"FUNCTION (#{self.class}) EXPECTS 2 ARGUMENTS BUT GOT #{params.length}")
  end
end

.signatureObject



43
44
45
# File 'lib/rvm/functions/array/at.rb', line 43

def signature
  [:list, :number]
end