Class: EMN::Monitor::Mail
- Inherits:
-
Object
- Object
- EMN::Monitor::Mail
- Defined in:
- lib/emn/monitor/mail.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(config) ⇒ Mail
constructor
A new instance of Mail.
- #notifications ⇒ Object
- #seen ⇒ Object
Constructor Details
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
4 5 6 |
# File 'lib/emn/monitor/mail.rb', line 4 def api @api end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/emn/monitor/mail.rb', line 4 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/emn/monitor/mail.rb', line 4 def logger @logger end |
Instance Method Details
#notifications ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/emn/monitor/mail.rb', line 16 def notifications notifications = { :template => "templates/mail.erb", :subject => "Eve Mail", :seen => config.seen, :data => {} } api.characters.each do |toon| logger.debug("Checking character %s" % toon.name) = api.mails(toon) logger.debug("Found %d messages for %s" % [.size, toon.name]) .each do |mail| logger.debug("Processing email %s: from: %s subject: %s" % [mail., mail.senderName, mail.title]) seen[:mail][toon.name] ||= "0" if seen[:mail][toon.name] < mail. seen[:mail][toon.name] = mail. if mail.senderName == toon.name logger.debug("Skipping mail %s as it's from the character" % mail.) next end logger.debug("Adding email %s: %s to the queue" % [mail., mail.title]) notifications[:data][toon.name] ||= [] notifications[:data][toon.name] << { :id => mail., :from => mail.senderName, :date => mail.sentDate, :subject => mail.title } else logger.debug("Skipping email %s: it's been seen before (%s)" % [mail., seen[:mail][toon.name]]) end end end notifications[:seen] = seen notifications end |
#seen ⇒ Object
12 13 14 |
# File 'lib/emn/monitor/mail.rb', line 12 def seen @seen ||= {:mail => config.seen.fetch(:mail, {})} end |