Class: Rserve::RVector

Inherits:
R2rb::RVector show all
Defined in:
lib/R4rb/Rserve.rb

Instance Attribute Summary collapse

Attributes inherited from R2rb::RVector

#name, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from R2rb::RVector

#>, #[], #arg=, #get, #get_with_arg, #length, #set, #set_arg, #valid?

Constructor Details

#initialize(name, cli = nil) ⇒ RVector

The goal is to connect a ruby Array to a Rserve Vector



168
169
170
171
172
173
174
# File 'lib/R4rb/Rserve.rb', line 168

def initialize(name,cli=nil)
	@cli=(cli ? cli : Rserve.cli)
	puts "WARNING: Rserve::RVector.initialize: @cli is null!" unless @cli
	@name_orig=name
	super(name!)
	@type="expr"
end

Instance Attribute Details

#cliObject

Returns the value of attribute cli.



165
166
167
# File 'lib/R4rb/Rserve.rb', line 165

def cli
  @cli
end

Class Method Details

.assign(var, ary, cli = nil) ⇒ Object



160
161
162
163
# File 'lib/R4rb/Rserve.rb', line 160

def RVector.assign(var,ary,cli=nil)
	super(var,ary)
	Rserve.assign(var,var,cli)
end

Instance Method Details

#<(ary) ⇒ Object Also known as: value=

no need to make aby change for “>”



191
192
193
194
# File 'lib/R4rb/Rserve.rb', line 191

def <(ary)
	ary.R2rb(".rubyExport") #transition
	Rserve.assign(".rubyExport",@name_orig,@cli)
end

#<<(name) ⇒ Object



182
183
184
185
186
187
# File 'lib/R4rb/Rserve.rb', line 182

def <<(name)
			## no "var" in this context! transform it in String if necessary
    @name_orig=name.to_s
    super(name!)
  	return self
end

#name!Object

name from cli and name_orig



176
177
178
179
180
# File 'lib/R4rb/Rserve.rb', line 176

def name! #name from cli and name_orig
	##puts "name!";p @name_orig
	##deb,fin="quote(",")" #(@name_orig=~/^evalq\(/ ? ["quote(",")"] : ["\"","\""])
	"RSeval(#{@cli},quote(#{@name_orig}))"
end

#set_with_arg(ary) ⇒ Object Also known as: value_with_arg=



198
199
200
201
202
203
# File 'lib/R4rb/Rserve.rb', line 198

def set_with_arg(ary)
	ary=[ary] unless ary.is_a? Array
	ary.R2rb(".rubyExport") #transition
	#p @name_orig+@arg
	Rserve.assign(".rubyExport",@name_orig+@arg,@cli)
end