Class: R::Environment

Inherits:
Object
  • Object
show all
Includes:
IndexedObject
Defined in:
lib/R_interface/renvironment.rb

Overview



Constant Summary

Constants inherited from Object

Object::EXPLICIT_RUBY_SURFACE

Instance Attribute Summary

Attributes inherited from Object

#expression, #r_interop

Instance Method Summary collapse

Methods included from IndexedObject

#[], #[]=, #size

Methods inherited from Object

#==, build, build_class_probe_count, build_from_r_class_string, build_from_wrapper_tag, #call, class_probe_fetch_r_class, increment_build_class_probe_count!, #initialize, #inspect, #instance_of?, #instance_variable_get, #instance_variable_set, #is_a?, #nil?, #pretty_print, #rclass, reset_build_counters!, #respond_to?, #send, #to_ary, #to_i, #to_ruby, #to_s, #typeof, #unboxed_get

Methods included from ExecUniOp

#exec_uni_oper

Methods included from UnaryOperators

#!, #+@, #-@

Methods included from ExecBinOp

#coerce, #exec_bin_oper

Methods included from BinaryOperators

#!=, #%, #*, #**, #+, #-, #/, #<, #<=, #>, #>=, #_, #eq, #int_div, #til

Constructor Details

This class inherits a constructor from R::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object





57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/R_interface/renvironment.rb', line 57

def method_missing(symbol, *args, &block)
  name = ::R::Support.convert_symbol2r(symbol)

  case
  when name =~ /(.*)=$/
    set($1, args[0])
  when name == "env_names"
    # Call R's env_names(env) from Environment so .length is vector length (1), not string length.
    ::R::Support.exec_function("env_names", self, unbox: false)
  else
    super(symbol, *args, &block)
  end
end

Instance Method Details

#classObject



33
34
35
# File 'lib/R_interface/renvironment.rb', line 33

def class
  ::R::Environment
end

#get(key) ⇒ Object





49
50
51
# File 'lib/R_interface/renvironment.rb', line 49

def get(key)
  ::R.get(key.to_s, pos: self)
end

#set(key, value) ⇒ Object





41
42
43
# File 'lib/R_interface/renvironment.rb', line 41

def set(key, value)
  ::R.assign(key.to_s, value, pos: self)
end