Module: RType::Helper::RObjDelegatable

Extended by:
ClassMethods
Includes:
CoreExt::BooleanDelegateR, CoreExt::NumericDelegateR
Included in:
Base, Matrix
Defined in:
lib/r_type/helper/robj_delegatable.rb,
lib/r_type/helper/robj_delegatable_class_methods.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

delegate_constructor, delegate_to_R

Methods included from CoreExt::NumericDelegateR

#*

Class Method Details

.included(klass) ⇒ Object



10
11
12
# File 'lib/r_type/helper/robj_delegatable.rb', line 10

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#==(obj) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/r_type/helper/robj_delegatable.rb', line 52

def == obj
  if obj.is_a?(RObjDelegatable)
    self.robj == obj.robj || !!R['identical'].call(self, obj)
  else
    super
  end
end

#__getobj__Object



14
15
16
# File 'lib/r_type/helper/robj_delegatable.rb', line 14

def __getobj__
  to_ruby
end

#as_rObject



40
41
42
# File 'lib/r_type/helper/robj_delegatable.rb', line 40

def as_r
  robj.as_r
end

#inspectObject



48
49
50
# File 'lib/r_type/helper/robj_delegatable.rb', line 48

def inspect
  "RType::#{(@robj || @ruby_obj).inspect}"
end

#robjObject



18
19
20
21
22
# File 'lib/r_type/helper/robj_delegatable.rb', line 18

def robj
  @robj ||= convert_ruby_to_robj.tap do |newobj|
    @ruby_obj = nil unless newobj.nil?
  end
end

#robj=(obj) ⇒ Object



30
31
32
33
# File 'lib/r_type/helper/robj_delegatable.rb', line 30

def robj= obj
  @ruby_obj = nil
  @robj = obj
end

#ruby_objObject



24
25
26
27
28
# File 'lib/r_type/helper/robj_delegatable.rb', line 24

def ruby_obj
  @ruby_obj ||= convert_robj_to_ruby.tap do |newobj|
    @robj = nil unless newobj.nil?
  end
end

#ruby_obj=(obj) ⇒ Object



35
36
37
38
# File 'lib/r_type/helper/robj_delegatable.rb', line 35

def ruby_obj= obj
  @robj = nil
  @ruby_obj = obj
end

#to_ruby(mode = nil) ⇒ Object



44
45
46
# File 'lib/r_type/helper/robj_delegatable.rb', line 44

def to_ruby mode = nil
  ruby_obj
end