Class: RObject::Base

Inherits:
RObj
  • Object
show all
Defined in:
lib/robject/base.rb

Direct Known Subclasses

Array, DataFrame, Function, List, Matrix, Numeric, String, Vector

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(robj) ⇒ Base

Returns a new instance of Base.



23
24
25
26
# File 'lib/robject/base.rb', line 23

def initialize robj
  @robj = robj
  super robj
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



28
29
30
31
32
33
34
# File 'lib/robject/base.rb', line 28

def method_missing name, *args, &block
  if name =~ /^[\-+*\/!><&|\^]+$/
    R[name.to_s].call @robj, *args
  else
    super
  end
end

Instance Attribute Details

#robjObject (readonly)

Returns the value of attribute robj.



4
5
6
# File 'lib/robject/base.rb', line 4

def robj
  @robj
end

Class Method Details

.delegate_to_R(from_to) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/robject/base.rb', line 6

def self.delegate_to_R from_to
  from_to.each do |from, to|
    define_method(from) do |*args|
      R[to].call @robj, *args
    end
  end
end

.match?(robj, type) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/robject/base.rb', line 14

def self.match? robj, type
  true
end

Instance Method Details

#__getobj__Object



36
37
38
# File 'lib/robject/base.rb', line 36

def __getobj__
  to_ruby
end

#as_rObject



40
41
42
# File 'lib/robject/base.rb', line 40

def as_r
  @robj.as_r
end

#is_function?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/robject/base.rb', line 48

def is_function?
  R.rsruby.is_function(@robj).to_ruby
end

#to_ruby(mode = ::RSRuby::BASIC_CONVERSION) ⇒ Object



44
45
46
# File 'lib/robject/base.rb', line 44

def to_ruby mode = ::RSRuby::BASIC_CONVERSION
  @robj.to_ruby mode
end