Class: GReader::Entries
- Inherits:
-
Array
- Object
- Array
- GReader::Entries
- Includes:
- Utilities
- Defined in:
- lib/greader/entries.rb
Overview
Entries list
Common usage
This is what’s returned by methods like Feed#entries and Tag#entries.
entries = tag.entries
It’s a simple array so just use it like so:
entries.each { |entry| puts entry }
entries.size #=> 20
You can also lookup by id:
feeds.entries['ENTRY_ID']
But you can have it load more entries:
entries.more
entries.each { |entry| puts entry }
entries.size #=> 40
Internal usage
Pass it an Atom URL.
Entries.fetch @client, @client.atom_url(xxx)
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#continuation ⇒ Object
readonly
Continuation token (don’t use).
Class Method Summary collapse
-
.fetch(client, url, options = {}) ⇒ Object
Fetch from atom.
Instance Method Summary collapse
- #+(other) ⇒ Object
-
#[](id) ⇒ Object
Lookup.
-
#initialize(contents, client, options = {}) ⇒ Entries
constructor
A new instance of Entries.
- #more ⇒ Object
Methods included from Utilities
#escape, #kv_map, #slug, #strip_tags
Constructor Details
#initialize(contents, client, options = {}) ⇒ Entries
Returns a new instance of Entries.
50 51 52 53 54 55 |
# File 'lib/greader/entries.rb', line 50 def initialize(contents, client, ={}) super contents @continuation = [:continuation] @url = [:url] @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
38 39 40 |
# File 'lib/greader/entries.rb', line 38 def client @client end |
#continuation ⇒ Object (readonly)
Continuation token (don’t use)
37 38 39 |
# File 'lib/greader/entries.rb', line 37 def continuation @continuation end |
Class Method Details
.fetch(client, url, options = {}) ⇒ Object
Fetch from atom
41 42 43 44 45 46 47 48 |
# File 'lib/greader/entries.rb', line 41 def self.fetch(client, url, ={}) doc = client.json_get(url, to_params()) contents = doc['items'].map do |node| Entry.new client, Entry.parse_json(node) end new contents, client, .merge(:url => url) end |
Instance Method Details
#+(other) ⇒ Object
61 62 63 |
# File 'lib/greader/entries.rb', line 61 def +(other) # end |
#[](id) ⇒ Object
Lookup
66 67 68 |
# File 'lib/greader/entries.rb', line 66 def [](id) indices[slug(id)] end |
#more ⇒ Object
57 58 59 |
# File 'lib/greader/entries.rb', line 57 def more # self + fetch(@client, @url, :from => @continuation) end |