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.



195
196
197
# File 'lib/rscript.rb', line 195

def type
  @type
end

Instance Method Details

#read(args = []) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/rscript.rb', line 198

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