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.



514
515
516
517
518
# File 'lib/nexpose/report.rb', line 514

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.



512
513
514
# File 'lib/nexpose/report.rb', line 512

def email
  @email
end

#locationObject

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



510
511
512
# File 'lib/nexpose/report.rb', line 510

def location
  @location
end

#store_on_serverObject

Whether to store report on server.



508
509
510
# File 'lib/nexpose/report.rb', line 508

def store_on_server
  @store_on_server
end

Class Method Details

.parse(xml) ⇒ Object



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/nexpose/report.rb', line 529

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



520
521
522
523
524
525
526
527
# File 'lib/nexpose/report.rb', line 520

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