Class: SocialFeedAgregator::PinterestReader
- Inherits:
-
BaseReader
- Object
- BaseReader
- SocialFeedAgregator::PinterestReader
- Defined in:
- lib/social_feed_agregator/pinterest_reader.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #get_feeds(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PinterestReader
constructor
A new instance of PinterestReader.
Constructor Details
#initialize(options = {}) ⇒ PinterestReader
Returns a new instance of PinterestReader.
9 10 11 12 13 |
# File 'lib/social_feed_agregator/pinterest_reader.rb', line 9 def initialize(={}) super() .replace(SFA..merge()) @name = [:pinterest_user_name] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/social_feed_agregator/pinterest_reader.rb', line 7 def name @name end |
Instance Method Details
#get_feeds(options = {}) ⇒ Object
15 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 |
# File 'lib/social_feed_agregator/pinterest_reader.rb', line 15 def get_feeds(={}) super() @name = [:name] if [:name] count = [:count] || 25 from_date = [:from_date] || DateTime.new(1970,1,1) feeds = [] items = 0 doc = Nokogiri::XML( RestClient.get("http://pinterest.com/#{@name}/feed.rss") ) doc.xpath('//item').each do |item| items += 1 break if items > count # Break if the date is less if DateTime.parse(item.xpath('pubDate').inner_text) <= from_date break end feed = fill_feed item block_given? ? yield(feed) : feeds << feed end feeds end |