Class: Nexpose::Frequency

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/report.rb

Overview

Data object associated with when a report is generated.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(after_scan, scheduled, schedule = nil) ⇒ Frequency

Returns a new instance of Frequency.



467
468
469
470
471
# File 'lib/nexpose/report.rb', line 467

def initialize(after_scan, scheduled, schedule = nil)
  @after_scan = after_scan
  @scheduled = scheduled
  @schedule = schedule
end

Instance Attribute Details

#after_scanObject

Will the report be generated after a scan completes (true), or is it ad hoc/scheduled (false).



461
462
463
# File 'lib/nexpose/report.rb', line 461

def after_scan
  @after_scan
end

#scheduleObject

Schedule associated with the report.



465
466
467
# File 'lib/nexpose/report.rb', line 465

def schedule
  @schedule
end

#scheduledObject

Whether or not a scan is scheduled.



463
464
465
# File 'lib/nexpose/report.rb', line 463

def scheduled
  @scheduled
end

Class Method Details

.parse(xml) ⇒ Object



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/nexpose/report.rb', line 479

def self.parse(xml)
  xml.elements.each('//Generate') do |generate|
    if generate.attributes['after-scan'] == '1'
      return Frequency.new(true, false)
    else
      if generate.attributes['schedule'] == '1'
        generate.elements.each('Schedule') do |sched|
          schedule = Schedule.parse(sched)
          return Frequency.new(false, true, schedule)
        end
      end
      return Frequency.new(false, false)
    end
  end
  nil
end

Instance Method Details

#to_xmlObject



473
474
475
476
477
# File 'lib/nexpose/report.rb', line 473

def to_xml
  xml = %(<Generate after-scan="#{@after_scan ? 1 : 0}" schedule="#{@scheduled ? 1 : 0}">)
  xml << @schedule.to_xml if @schedule
  xml << '</Generate>'
end