Class: Rserve::REXP::Environment

Inherits:
Rserve::REXP show all
Defined in:
lib/rserve/rexp/environment.rb

Overview

REXPEnvironment represents an environment in R. Very much like org.rosuda.REngine.REXPReference this is a proxy object to the actual object on the R side. It provides methods for accessing the content of the environment. The actual implementation may vary by the back-end used and not all engines support environments. Check org.rosuda.REngine.REngine.supportsEnvironments() for the given engine. Environments are specific for a given engine, they cannot be passed across engines

Constant Summary

Constants inherited from Rserve::REXP

MaxDebugItems, MismatchError

Instance Attribute Summary collapse

Attributes inherited from Rserve::REXP

#attr

Instance Method Summary collapse

Methods inherited from Rserve::REXP

#as_bytes, #as_double, #as_double_matrix, #as_doubles, #as_factor, #as_float, #as_floats, #as_integer, #as_integers, #as_list, #as_matrix, #as_nested_array, #as_string, #as_strings, #complex?, create_data_frame, #dim, #expression?, #factor?, #get_attribute, #has_attribute?, #inherits?, #integer?, #language?, #length, #list?, #logical?, #na?, #null?, #numeric?, #pair_list?, #raw?, #recursive?, #reference?, #split_array, #string?, #symbol?, #to_debug_string, #to_f, #to_i, #to_ruby, #to_ruby_internal, #vector?

Constructor Details

#initialize(e, h) ⇒ Environment

create a new environemnt reference - this constructor should never be used directly, use REngine.newEnvironment() instead.

  • @param eng engine responsible for this environment

  • @param handle handle used by the engine to identify this environment



10
11
12
13
14
# File 'lib/rserve/rexp/environment.rb', line 10

def initialize(e,h)
  super()
  @eng = e
  @handle = h
end

Instance Attribute Details

#engObject (readonly)

Returns the value of attribute eng.



5
6
7
# File 'lib/rserve/rexp/environment.rb', line 5

def eng
  @eng
end

#handleObject (readonly)

Returns the value of attribute handle.



6
7
8
# File 'lib/rserve/rexp/environment.rb', line 6

def handle
  @handle
end

Instance Method Details

#assign(name, value) ⇒ Object

assigns a value to a given symbol name

@param name symbol name
@param value value */


29
30
31
# File 'lib/rserve/rexp/environment.rb', line 29

def assign(name, value)
  @eng.assign(name, value, self)
end

#environment?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rserve/rexp/environment.rb', line 15

def environment?
  true
end

#get(name, resolve = true) ⇒ Object

get a value from this environment

  • @param name name of the value

  • @param resolve if false returns a reference to the object, if false the reference is resolved

  • @return value corresponding to the symbol name or possibly null if the value is unbound (the latter is currently engine-specific)



23
24
25
# File 'lib/rserve/rexp/environment.rb', line 23

def get(name, resolve=true)
  @eng.get(name,self,resolve)
end

#parent(resolve = true) ⇒ Object



32
33
34
# File 'lib/rserve/rexp/environment.rb', line 32

def parent(resolve=true)
  @eng.get_parent_environment(self,resolve)
end