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.



430
431
432
433
434
# File 'lib/nexpose/report.rb', line 430

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



424
425
426
# File 'lib/nexpose/report.rb', line 424

def after_scan
  @after_scan
end

#scheduleObject

Schedule associated with the report.



428
429
430
# File 'lib/nexpose/report.rb', line 428

def schedule
  @schedule
end

#scheduledObject

Whether or not a scan is scheduled.



426
427
428
# File 'lib/nexpose/report.rb', line 426

def scheduled
  @scheduled
end

Class Method Details

.parse(xml) ⇒ Object



442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/nexpose/report.rb', line 442

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



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

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