Class: R2rb::RConsole

Inherits:
Object show all
Defined in:
lib/R4rb/init.rb,
lib/R4rb/R2rb_init.rb

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

Constructor Details

#initializeRConsole

Returns a new instance of RConsole.



64
65
66
# File 'lib/R4rb/init.rb', line 64

def initialize
  require "readline"
end

Instance Method Details

#execObject



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

#init(args) ⇒ Object



68
69
70
# File 'lib/R4rb/init.rb', line 68

def init args
  R2rb.init args
end