Class: ClamScan::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/clam_scan/request.rb

Class Method Summary collapse

Class Method Details

.send(opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/clam_scan/request.rb', line 4

def send (opts={})
  output_lines = []

  begin
    IO.popen(popen_args(opts), 'r+') do |f|
      if opts[:stream]
        f.write opts[:stream]
        f.close_write
      end
      while line = f.gets
        output_lines << line
      end
    end
  rescue SystemCallError => e
    raise RequestError, "An error occured while making system call to #{::ClamScan.configuration.client_location}: #{e.to_s}"
  end

  output_string = output_lines.join("\n")
  Response.new($?, output_string)
end