Class: RScriptRW

Inherits:
RScript
  • Object
show all
Defined in:
lib/rsf_services.rb

Direct Known Subclasses

RSFServices

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log: log) ⇒ RScriptRW

Returns a new instance of RScriptRW.



13
14
15
# File 'lib/rsf_services.rb', line 13

def initialize(log: log)
  super(log: log)
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/rsf_services.rb', line 11

def type
  @type
end

Instance Method Details

#read(args = []) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rsf_services.rb', line 17

def read(args=[])
  
  @log.info 'RScript/read: args: '  + args.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!

    a = read_rsfdoc(args)      
    job = a.find do |xy| 
      name, x = xy
      name == ajob.to_sym and 
          (x[:attributes][:type] || 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