Class: R::Environment

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

Overview



Instance Attribute Summary

Attributes inherited from Object

#r_interop, #statement

Instance Method Summary collapse

Methods included from IndexedObject

#[], #[]=, #size

Methods inherited from Object

#==, #_, #attr=, build, #comment, #comment=, #dim, #dim=, #dimnames, #dimnames=, #eql, #initialize, #names, #names=, #pp, #pretty_print, #rclass, #rclass=, #row__names, #row__names=, #setR, #setR_name, #to_s, #tsp, #tsp=

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





53
54
55
56
57
58
59
60
61
62
63
# File 'lib/R_interface/renvironment.rb', line 53

def method_missing(symbol, *args, &block)

  name = R::Support.convert_symbol2r(symbol)

  case
  when name =~ /(.*)=$/
    set($1, args[0])
  else
    super(symbol, *args, &block)
  end
end

Instance Method Details

#get(key) ⇒ Object





45
46
47
# File 'lib/R_interface/renvironment.rb', line 45

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

#set(key, value) ⇒ Object





37
38
39
# File 'lib/R_interface/renvironment.rb', line 37

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