Class: RScriptRW

Inherits:
RScript show all
Defined in:
lib/rscript.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RScript

#initialize, #jobs, #reset, #run

Methods inherited from RScriptBase

#initialize

Constructor Details

This class inherits a constructor from RScript

Instance Attribute Details

#typeObject

Returns the value of attribute type.



52
53
54
# File 'lib/rscript.rb', line 52

def type
  @type
end

Instance Method Details

#read(args = []) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
# File 'lib/rscript.rb', line 55

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