Sha256: 77ed0c874c656740a3c9ff1987acc934ac371a7e9835025b4639a8deaca78f3b

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module Ddr
  module Antivirus
    #
    # Default scan result implementation
    # 
    class ScanResult
      
      attr_reader :raw, :file_path, :scanned_at, :version
      
      def initialize(raw, file_path, opts={})
        @raw = raw
        @file_path = file_path
        @scanned_at = opts.fetch(:scanned_at, default_time)
        @version = opts.fetch(:version, default_version)
      end

      def default_time
        Time.now.utc
      end

      def default_version
        "ddr-antivirus #{Ddr::Antivirus::VERSION}"
      end

      # Subclasses may override to provide description of virus found.
      def virus_found; end

      # Subclasses should override
      def has_virus?
        !virus_found.nil?
      end

      # Subclasses may override to indicate an error condition (not necessarily an exception).
      def error?
        false
      end

      def ok?
        !(has_virus? || error?)
      end

      # Subclasses may override
      def to_s
        "#{raw} (#{version})"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddr-antivirus-1.2.1 lib/ddr/antivirus/scan_result.rb
ddr-antivirus-1.2.0 lib/ddr/antivirus/scan_result.rb