Class: ClamScan::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_status, output) ⇒ Response

Returns a new instance of Response.



6
7
8
9
# File 'lib/clam_scan/response.rb', line 6

def initialize (process_status, output)
  @output = output
  @process_status = process_status
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



3
4
5
# File 'lib/clam_scan/response.rb', line 3

def output
  @output
end

#process_statusObject

Returns the value of attribute process_status.



4
5
6
# File 'lib/clam_scan/response.rb', line 4

def process_status
  @process_status
end

Instance Method Details

#bodyObject



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

def body
  @output
end

#error?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/clam_scan/response.rb', line 15

def error?
  status == :error
end

#safe?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/clam_scan/response.rb', line 19

def safe?
  status == :safe
end

#statusObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/clam_scan/response.rb', line 23

def status
  case @process_status.exitstatus
    when 0
      :safe
    when 1
      :virus
    when 2
      :error
    else
      :unknown
  end
end

#unknown?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/clam_scan/response.rb', line 36

def unknown?
  status == :unknown
end

#virus?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/clam_scan/response.rb', line 40

def virus?
  status == :virus
end