Class: Nexpose::SMTPAlert
- Inherits:
-
Object
- Object
- Nexpose::SMTPAlert
- 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 e-mail 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 alert.
- #as_xml ⇒ Object
-
#initialize(sender, server, limit_text = 0) ⇒ SMTPAlert
constructor
A new instance of SMTPAlert.
- #to_xml ⇒ Object
Constructor Details
#initialize(sender, server, limit_text = 0) ⇒ SMTPAlert
Returns a new instance of SMTPAlert.
214 215 216 217 218 219 |
# File 'lib/nexpose/alert.rb', line 214 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.
210 211 212 |
# File 'lib/nexpose/alert.rb', line 210 def limit_text @limit_text end |
#recipients ⇒ Object
Array of strings with the e-mail addresses of the intended recipients.
212 213 214 |
# File 'lib/nexpose/alert.rb', line 212 def recipients @recipients end |
#sender ⇒ Object
The e-mail address of the sender.
206 207 208 |
# File 'lib/nexpose/alert.rb', line 206 def sender @sender end |
#server ⇒ Object
The server to sent this alert.
208 209 210 |
# File 'lib/nexpose/alert.rb', line 208 def server @server end |
Class Method Details
.parse(xml) ⇒ Object
243 244 245 246 247 248 249 |
# File 'lib/nexpose/alert.rb', line 243 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 alert.
222 223 224 |
# File 'lib/nexpose/alert.rb', line 222 def add_recipient(recipient) @recipients << recipient end |
#as_xml ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/nexpose/alert.rb', line 226 def as_xml xml = REXML::Element.new('smtpAlert') xml.attributes['sender'] = @sender xml.attributes['server'] = @server xml.attributes['limitText'] = @limit_text recipients.each do |recpt| elem = REXML::Element.new('recipient') elem.text = recpt xml.add_element(elem) end xml end |
#to_xml ⇒ Object
239 240 241 |
# File 'lib/nexpose/alert.rb', line 239 def to_xml as_xml.to_s end |