Class: GoogleReaderApi::SubscriptionList

Inherits:
Object
  • Object
show all
Includes:
Enumerable, RssUtils
Defined in:
lib/google-reader-api-uniq/subscription_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ SubscriptionList

Returns a new instance of SubscriptionList.



10
11
12
13
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 10

def initialize(api)
  @api = api
  update
end

Instance Method Details

#add(url) ⇒ Object

subscribe to the given url google will set the title for you



38
39
40
41
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 38

def add(url)
  @api.post_link 'api/0/subscription/edit', :s => "feed/#{url}" , :ac => :subscribe 
  update
end

#eachObject



57
58
59
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 57

def each
  @feeds.each {|feed| yield feed}
end

#feedsObject



53
54
55
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 53

def feeds
  @feeds
end

#items_with_label(label) ⇒ Object

will return an array of entries with label



49
50
51
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 49

def items_with_label(label)
  create_entries(@api.get_link "atom/user/-/label/#{CGI::escape label}")
end

#remove_ifObject

yield each feed, if you return true the feed will be removed from your subscriptions



31
32
33
34
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 31

def remove_if
  each { |feed| feed.unsubscribe if yield feed}
  update
end

#total_unreadObject

returns the total unread count



16
17
18
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 16

def total_unread
  inject(0) {|i,j| i+j.unread_count}
end

#unread_countObject

returns a hash with following pattern: feed => unread_count



23
24
25
26
27
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 23

def unread_count
  hash = {}
  each { |feed| hash[feed] = feed.unread_count }
  hash
end

#unread_itemsObject

return an array of unread items



44
45
46
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 44

def unread_items
  feeds.map(&:all_unread_items)
end

#updateObject



61
62
63
# File 'lib/google-reader-api-uniq/subscription_list.rb', line 61

def update
  fetch_list
end