Class: Nexpose::Generate

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) ⇒ Generate

Returns a new instance of Generate.



441
442
443
444
445
# File 'lib/nexpose/report.rb', line 441

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).



435
436
437
# File 'lib/nexpose/report.rb', line 435

def after_scan
  @after_scan
end

#scheduleObject

Schedule associated with the report.



439
440
441
# File 'lib/nexpose/report.rb', line 439

def schedule
  @schedule
end

#scheduledObject

Whether or not a scan is scheduled.



437
438
439
# File 'lib/nexpose/report.rb', line 437

def scheduled
  @scheduled
end

Class Method Details

.parse(xml) ⇒ Object



453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/nexpose/report.rb', line 453

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

Instance Method Details

#to_xmlObject



447
448
449
450
451
# File 'lib/nexpose/report.rb', line 447

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