Class: WitchDoctor::Antivirus
- Inherits:
-
Object
- Object
- WitchDoctor::Antivirus
- Defined in:
- lib/witch_doctor/antivirus.rb
Constant Summary collapse
- RESULTS =
['Clean', 'VirusInfected', 'FileDownloadError']
Instance Attribute Summary collapse
-
#mount_point ⇒ Object
readonly
Returns the value of attribute mount_point.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #checked? ⇒ Boolean
- #clean? ⇒ Boolean
- #error? ⇒ Boolean
- #infected? ⇒ Boolean
-
#initialize(resource, mount_point) ⇒ Antivirus
constructor
A new instance of Antivirus.
- #latest_scan ⇒ Object
- #scheduled? ⇒ Boolean
Constructor Details
#initialize(resource, mount_point) ⇒ Antivirus
Returns a new instance of Antivirus.
6 7 8 9 |
# File 'lib/witch_doctor/antivirus.rb', line 6 def initialize(resource, mount_point) @resource = resource @mount_point = mount_point.to_s end |
Instance Attribute Details
#mount_point ⇒ Object (readonly)
Returns the value of attribute mount_point.
4 5 6 |
# File 'lib/witch_doctor/antivirus.rb', line 4 def mount_point @mount_point end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
4 5 6 |
# File 'lib/witch_doctor/antivirus.rb', line 4 def resource @resource end |
Instance Method Details
#checked? ⇒ Boolean
22 23 24 |
# File 'lib/witch_doctor/antivirus.rb', line 22 def checked? scheduled? && latest_scan.scan_result.present? end |
#clean? ⇒ Boolean
34 35 36 |
# File 'lib/witch_doctor/antivirus.rb', line 34 def clean? checked? && latest_scan.scan_result == 'Clean' end |
#error? ⇒ Boolean
30 31 32 |
# File 'lib/witch_doctor/antivirus.rb', line 30 def error? checked? && latest_scan.scan_result == 'FileDownloadError' end |
#infected? ⇒ Boolean
26 27 28 |
# File 'lib/witch_doctor/antivirus.rb', line 26 def infected? checked? && latest_scan.scan_result == 'VirusInfected' end |
#latest_scan ⇒ Object
11 12 13 14 15 16 |
# File 'lib/witch_doctor/antivirus.rb', line 11 def latest_scan @latest_scan ||= resource .virus_scans .select { |vs| vs.mount_point == mount_point } .last end |
#scheduled? ⇒ Boolean
18 19 20 |
# File 'lib/witch_doctor/antivirus.rb', line 18 def scheduled? !latest_scan.nil? end |