Class: Nexpose::Section

Inherits:
Object
  • Object
show all
Includes:
Sanitize
Defined in:
lib/nexpose/report_template.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.



221
222
223
224
# File 'lib/nexpose/report_template.rb', line 221

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

Instance Attribute Details

#nameObject

Name of the report section.



217
218
219
# File 'lib/nexpose/report_template.rb', line 217

def name
  @name
end

#propertiesObject

Map of properties specific to the report section.



219
220
221
# File 'lib/nexpose/report_template.rb', line 219

def properties
  @properties
end

Class Method Details

.parse(xml) ⇒ Object



236
237
238
239
240
241
242
243
244
245
246
# File 'lib/nexpose/report_template.rb', line 236

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



228
229
230
231
232
233
234
# File 'lib/nexpose/report_template.rb', line 228

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