Class: R2rb::RConsole
Overview
class RVector
def <<(name)
if name.is_a? Symbol
@name=name.to_s
@type="var"
else
@name=name
@type="expr"
end
return self
end
def >(arr)
arr.replace(self.get)
return self
end
end
Instance Method Summary collapse
- #exec ⇒ Object
- #init(args) ⇒ Object
-
#initialize ⇒ RConsole
constructor
A new instance of RConsole.
Constructor Details
#initialize ⇒ RConsole
Returns a new instance of RConsole.
64 65 66 |
# File 'lib/R4rb/init.rb', line 64 def initialize require "readline" end |
Instance Method Details
#exec ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/R4rb/init.rb', line 72 def exec #todo : continuation toggle=true fin=false words=[] rvect=R2rb::RVector.new("") Readline.completion_proc=Proc.new {|e| cpt=0 begin begin cpt += 1 toggle = !toggle rvect << (toggle ? "apropos(" : "ls(pat=")+"'^"+e+"')" > words res=words.map{|w| w[Regexp.new("^"+e+".*")]}-[nil] end while res.empty? and cpt<3 res rescue warn("\r"+e+" not suitable for completion!!!") [] end } Readline.completion_append_character="" begin line = Readline.readline("R> ", true) if !(fin = line=="quit") R2rb.eval line,true toggle=true end end until fin end |