Class: Nexpose::SMTPAlert
- Inherits:
-
Object
- Object
- Nexpose::SMTPAlert
- Includes:
- Sanitize
- Defined in:
- lib/nexpose/alert.rb
Overview
SMTP (e-mail) Alert This class should only exist as an element of an Alert.
Instance Attribute Summary collapse
-
#limit_text ⇒ Object
Limit the text for mobile devices.
-
#recipients ⇒ Object
Array of strings with the e-mail addresses of the intended recipients.
-
#sender ⇒ Object
The email address of the sender.
-
#server ⇒ Object
The server to sent this alert.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_recipient(recipient) ⇒ Object
Adds a new Recipient to the recipients array.
-
#initialize(sender, server, limit_text = 0) ⇒ SMTPAlert
constructor
A new instance of SMTPAlert.
- #to_xml ⇒ Object
Methods included from Sanitize
Constructor Details
#initialize(sender, server, limit_text = 0) ⇒ SMTPAlert
Returns a new instance of SMTPAlert.
206 207 208 209 210 211 |
# File 'lib/nexpose/alert.rb', line 206 def initialize(sender, server, limit_text = 0) @sender = sender @server = server @limit_text = limit_text @recipients = [] end |
Instance Attribute Details
#limit_text ⇒ Object
Limit the text for mobile devices
201 202 203 |
# File 'lib/nexpose/alert.rb', line 201 def limit_text @limit_text end |
#recipients ⇒ Object
Array of strings with the e-mail addresses of the intended recipients.
204 205 206 |
# File 'lib/nexpose/alert.rb', line 204 def recipients @recipients end |
#sender ⇒ Object
The email address of the sender
195 196 197 |
# File 'lib/nexpose/alert.rb', line 195 def sender @sender end |
#server ⇒ Object
The server to sent this alert
198 199 200 |
# File 'lib/nexpose/alert.rb', line 198 def server @server end |
Class Method Details
.parse(xml) ⇒ Object
231 232 233 234 235 236 237 |
# File 'lib/nexpose/alert.rb', line 231 def self.parse(xml) alert = new(xml.attributes['sender'], xml.attributes['server'], xml.attributes['limitText'].to_i) xml.elements.each("//recipient") do |recipient| alert.recipients << recipient.text end alert end |
Instance Method Details
#add_recipient(recipient) ⇒ Object
Adds a new Recipient to the recipients array
214 215 216 |
# File 'lib/nexpose/alert.rb', line 214 def add_recipient(recipient) @recipients << recipient end |
#to_xml ⇒ Object
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/nexpose/alert.rb', line 220 def to_xml xml = '<smtpAlert' xml << %Q( sender="#{replace_entities(sender)}") xml << %Q( server="#{replace_entities(server)}") xml << %Q( limitText="#{limit_text}">) recipients.each do |recpt| xml << "<recipient>#{replace_entities(recpt)}</recipient>" end xml << '</smtpAlert>' end |