Class: Eventify::Mail
- Inherits:
-
Object
- Object
- Eventify::Mail
- Defined in:
- lib/eventify/mail.rb
Class Method Summary collapse
Class Method Details
.deliver(new_events, configuration) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/eventify/mail.rb', line 5 def deliver(new_events, configuration) formatted_events = format(new_events) configuration[:subscribers].each do |subscriber| ::Mail.deliver do delivery_method :smtp, configuration[:mail] content_type "text/plain; charset=utf-8" to subscriber from "Eventify <[email protected]>" subject "Event Rumours" body formatted_events end end end |
.format(events) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eventify/mail.rb', line 22 def format(events) header = "There are some rumours going on about #{events.size} possible awesome events:" formatted_events = events.sort.reduce([header, ""]) do |memo, event| memo << "* #{event.title}".force_encoding("UTF-8") memo << " #{event.link}".force_encoding("UTF-8") memo << "" end = "Your Humble Servant,\nEventify" formatted_events << formatted_events.join("\n") end |