Class: Feed2Mail::Report
- Inherits:
-
Object
- Object
- Feed2Mail::Report
- Defined in:
- lib/feed2mail/report.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
-
#initialize(config) ⇒ Report
constructor
A new instance of Report.
- #mail(opts) ⇒ Object
- #seen?(item) ⇒ Boolean
- #to_s ⇒ Object
- #update ⇒ Object
Constructor Details
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
5 6 7 |
# File 'lib/feed2mail/report.rb', line 5 def items @items end |
Instance Method Details
#mail(opts) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/feed2mail/report.rb', line 26 def mail(opts) Pony.mail( :via_options => { :arguments => '-i' }, :charset => 'UTF-8', :from => opts[:from], :to => opts[:to], :subject => 'Feed2Mail: new feed items published', :body => to_s ) end |
#seen?(item) ⇒ Boolean
49 50 51 |
# File 'lib/feed2mail/report.rb', line 49 def seen?(item) @history.has?(item.uri) ? true : false end |
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/feed2mail/report.rb', line 13 def to_s out = '' @items.each do |i| out << <<-eoh #{i.title} #{i.uri} eoh end out end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/feed2mail/report.rb', line 37 def update @feeds.each do |f| f.items.each do |i| unless seen? i @items << i @history << i.uri end end end @history.save! end |