Class: Nexpose::Section
- Inherits:
-
Object
- Object
- Nexpose::Section
- Includes:
- Sanitize
- Defined in:
- lib/nexpose/report_template.rb
Overview
Section specific content to include in a report template.
Instance Attribute Summary collapse
-
#name ⇒ Object
Name of the report section.
-
#properties ⇒ Object
Map of properties specific to the report section.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Section
constructor
A new instance of Section.
- #to_xml ⇒ Object
Methods included from Sanitize
Constructor Details
#initialize(name) ⇒ Section
Returns a new instance of Section.
220 221 222 223 |
# File 'lib/nexpose/report_template.rb', line 220 def initialize(name) @name = name @properties = {} end |
Instance Attribute Details
#name ⇒ Object
Name of the report section.
216 217 218 |
# File 'lib/nexpose/report_template.rb', line 216 def name @name end |
#properties ⇒ Object
Map of properties specific to the report section.
218 219 220 |
# File 'lib/nexpose/report_template.rb', line 218 def properties @properties end |
Class Method Details
.parse(xml) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/nexpose/report_template.rb', line 235 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_xml ⇒ Object
227 228 229 230 231 232 233 |
# File 'lib/nexpose/report_template.rb', line 227 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 |