Method: RSRuby#method_missing

Defined in:
lib/rsruby.rb

#method_missing(r_id, *args) ⇒ Object

Handles method name conversion and calling of R functions If called without args the R function/varialbe is returned rather than called.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/rsruby.rb', line 131

def method_missing(r_id,*args)

  #Translate Ruby method call to R
  robj_name = RSRuby.convert_method_name(r_id.to_s)

  #Retrieve it
  robj = self.__getitem__(robj_name)

  #TODO perhaps this is not neccessary - always call these methods
  #use the [] syntax for variables etc...
  if args.length > 0

    #convert arguments to lcall format
    lcall_args = RSRuby.convert_args_to_lcall(args)
    
    #Return result of calling object with lcall 
    #formatted args
    return robj.lcall(lcall_args)

  end

  return robj

end