Class: GReader::Entries

Inherits:
Array
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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, options={})
  super contents
  @continuation = options[:continuation]
  @url          = options[:url]
  @client       = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



38
39
40
# File 'lib/greader/entries.rb', line 38

def client
  @client
end

#continuationObject (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, options={})
  doc      = client.json_get(url, to_params(options))
  contents = doc['items'].map do |node|
    Entry.new client, Entry.parse_json(node)
  end

  new contents, client, options.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

#moreObject



57
58
59
# File 'lib/greader/entries.rb', line 57

def more
  # self + fetch(@client, @url, :from => @continuation)
end