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, debug: debug) ⇒ RScriptRW

Returns a new instance of RScriptRW.



15
16
17
18
# File 'lib/rsf_services.rb', line 15

def initialize(log: log, debug: debug)
  @type = :get
  super(log: log, debug: debug)
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#read(args = []) ⇒ Object



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
56
57
58
59
60
61
62
63
64
# File 'lib/rsf_services.rb', line 20

def read(args=[])
  
  puts 'inside read' if @debug
  @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!
    
    if @debug then
      puts 'type: ' + 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] || 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