Class: Google::Reader::Label
- Defined in:
- lib/google/reader/label.rb
Constant Summary collapse
- VALID_KEYS =
[:n, :c]
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#shared ⇒ Object
Returns the value of attribute shared.
Class Method Summary collapse
-
.all ⇒ Object
Usage: Google::Reader::Label.all.
Instance Method Summary collapse
-
#entries(which = nil, o = {}) ⇒ Object
Usage: Google::Reader::Label.new(‘friends’).entries Google::Reader::Label.new(‘friends’).entries(:all, :n => 25) Google::Reader::Label.new(‘friends’).entries(:unread) Google::Reader::Label.new(‘friends’).entries(:unread, :n => 25).
-
#initialize(name, shared = false, count = 0) ⇒ Label
constructor
Usage: Google::Reader::Label.new(‘friends’) Google::Reader::Label.new(‘friends’, false) Google::Reader::Label.new(‘friends’, false, 3).
-
#name ⇒ Object
Returns name; converts broadcast label to shared to be consistent with google.
-
#name=(new_name) ⇒ Object
Converts user/user-id/label/security to security.
Methods inherited from Base
get_entries, get_token, parse, parse_json, user_info
Constructor Details
#initialize(name, shared = false, count = 0) ⇒ Label
23 24 25 26 27 |
# File 'lib/google/reader/label.rb', line 23 def initialize(name, shared=false, count=0) self.name = name self.shared = shared self.count = count end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
17 18 19 |
# File 'lib/google/reader/label.rb', line 17 def count @count end |
#shared ⇒ Object
Returns the value of attribute shared.
16 17 18 |
# File 'lib/google/reader/label.rb', line 16 def shared @shared end |
Class Method Details
.all ⇒ Object
7 8 9 10 11 |
# File 'lib/google/reader/label.rb', line 7 def all parse_json(get(LABELS_URL))['tags'].inject([]) do |labels, l| labels << new(l['id'], l['shared']) end end |
Instance Method Details
#entries(which = nil, o = {}) ⇒ Object
Usage:
Google::Reader::Label.new('friends').entries
Google::Reader::Label.new('friends').entries(:all, :n => 25)
Google::Reader::Label.new('friends').entries(:unread)
Google::Reader::Label.new('friends').entries(:unread, :n => 25)
To use with continuations:
unread = Google::Reader::Label.new('friends').entries(:unread)
next_unread = Google::Reader::Label.new('friends').entries(:unread, :c => unread.continuation)
The examples above would grab the first 15 unread entries and then using google reader’s continuations, the next 15 unread after the first 15.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/google/reader/label.rb', line 59 def entries(which=nil, o={}) = {:n => 15,}.merge(o) query_str = valid_keys_to_query_string(o) url = case which.to_s when 'unread' sprintf(LABEL_URL, @name) + "?xt=#{State::READ}&#{query_str}" else sprintf(LABEL_URL, @name) end self.class.get_entries(url, :continuation => true) end |
#name ⇒ Object
Returns name; converts broadcast label to shared to be consistent with google
35 36 37 |
# File 'lib/google/reader/label.rb', line 35 def name @name == 'broadcast' ? 'shared' : @name end |
#name=(new_name) ⇒ Object
Converts user/user-id/label/security to security.
30 31 32 |
# File 'lib/google/reader/label.rb', line 30 def name=(new_name) @name = new_name.split('/').last end |