Class: Nexpose::Section

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

Overview

Section specific content to include in a report template.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sanitize

#replace_entities

Constructor Details

#initialize(name) ⇒ Section

Returns a new instance of Section.



756
757
758
759
# File 'lib/nexpose/report.rb', line 756

def initialize(name)
  @name = name
  @properties = {}
end

Instance Attribute Details

#nameObject

Name of the report section.



752
753
754
# File 'lib/nexpose/report.rb', line 752

def name
  @name
end

#propertiesObject

Map of properties specific to the report section.



754
755
756
# File 'lib/nexpose/report.rb', line 754

def properties
  @properties
end

Class Method Details

.parse(xml) ⇒ Object



771
772
773
774
775
776
777
778
779
780
781
# File 'lib/nexpose/report.rb', line 771

def self.parse(xml)
  name = xml.attributes['name']
  xml.elements.each("//ReportSection[@name='#{name}']") do |elem|
    section = Section.new(name)
    elem.elements.each("//ReportSection[@name='#{name}']/property") do |property|
      section.properties[property.attributes['name']] = property.text
    end
    return section
  end
  nil
end

Instance Method Details

#to_xmlObject



763
764
765
766
767
768
769
# File 'lib/nexpose/report.rb', line 763

def to_xml
  xml = %Q{<ReportSection name='#{@name}'>}
  properties.each_pair do |name, value|
    xml << %Q{<property name='#{name}'>#{replace_entities(value)}</property>}
  end
  xml << '</ReportSection>'
end