class RScriptRW

Attributes

type[RW]

Public Instance Methods

read(args=[]) click to toggle source
# File lib/rscript.rb, line 197
def read(args=[])
  
  puts 'inside read' if @debug
  @log.info 'RScript/read: args: '  + args.inspect if @log
  @log.info 'RScript/read: type: '  + type.inspect if @log
  
  threads = []
  
  if args.to_s[/\/\/job:/] then 

    ajob = ''
    
    args.each_index do |i| 
      if args[i].to_s[/\/\/job:/] then          
        ajob = $'; args[i] = nil
      end
    end

    args.compact!
    
    if @debug then
      puts 'type: ' + self.type.to_s.inspect
      puts 'self.type: '  + self.type.to_s.inspect
    end

    a = read_rsfdoc(args)      
    job = a.find do |xy| 
      name, x = xy
      name == ajob.to_sym and 
          (x[:attributes][:type] || self.type.to_s) == self.type.to_s
    end.last

    out, attr = job[:code], job[:attributes]      
    
    raise "job not found" unless out.length > 0
    out
    
  else    
    out = read_rsfdoc(args).map {|x| x.last[:code]}.join("\n")
  end    
        
  @log.info 'RScript/read: code: '  + out.inspect if @log

  [out, args]    
  
end