Class: Nexpose::Delivery

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

Overview

Data object for configuration of where a report is stored or delivered.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store_on_server, location = nil, email = nil) ⇒ Delivery

Returns a new instance of Delivery.



493
494
495
496
497
# File 'lib/nexpose/report.rb', line 493

def initialize(store_on_server, location = nil, email = nil)
  @store_on_server = store_on_server
  @location = location
  @email = email
end

Instance Attribute Details

#emailObject

E-mail configuration.



491
492
493
# File 'lib/nexpose/report.rb', line 491

def email
  @email
end

#locationObject

Directory location to store report in (for non-default storage).



489
490
491
# File 'lib/nexpose/report.rb', line 489

def location
  @location
end

#store_on_serverObject

Whether to store report on server.



487
488
489
# File 'lib/nexpose/report.rb', line 487

def store_on_server
  @store_on_server
end

Class Method Details

.parse(xml) ⇒ Object



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/nexpose/report.rb', line 508

def self.parse(xml)
  xml.elements.each('//Delivery') do
    on_server = false
    location = nil
    xml.elements.each('//Storage') do |storage|
      on_server = true if storage.attributes['storeOnServer'] == '1'
      xml.elements.each('//location') do |loc|
        location = loc.text
      end
    end

    email = Email.parse(xml)

    return Delivery.new(on_server, location, email)
  end
  nil
end

Instance Method Details

#to_xmlObject



499
500
501
502
503
504
505
506
# File 'lib/nexpose/report.rb', line 499

def to_xml
  xml = '<Delivery>'
  xml << %(<Storage storeOnServer='#{@store_on_server ? 1 : 0}'>)
  xml << %(<location>#{@location}</location>) if @location
  xml << '</Storage>'
  xml << @email.to_xml if @email
  xml << '</Delivery>'
end