class ClamAV::Commands::Command

Public Instance Methods

call() click to toggle source
# File lib/clamav/commands/command.rb, line 25
def call; raise NotImplementedError.new; end

Protected Instance Methods

get_status_from_response(str) click to toggle source

OK response looks like “1: stream: OK” or “1: /tmp/NOT_A_VIRUS.TXT: OK” FOUND response looks like “1: stream: Eicar-Test-Signature FOUND” or “1: /tmp/EICAR.COM: Eicar-Test-Signature FOUND”

# File lib/clamav/commands/command.rb, line 31
def get_status_from_response(str)
  /^(?<id>\d+): (?<filepath>.*): (?<virus_name>.*)\s?(?<status>(OK|FOUND))$/ =~ str
  case status
  when 'OK' then ClamAV::SuccessResponse.new(filepath)
  when 'FOUND' then ClamAV::VirusResponse.new(filepath, virus_name.strip)
  else ClamAV::ErrorResponse.new(str)
  end
end