Class: GReader::Tag
Overview
A tag.
Common usage
Getting tags:
tag = @client.tag('TAG_ID') # see Tag#id below
Metadata:
tag.to_s #=> "Comics"
tag.id #=> "user/1000/tag/Comics"
Collections:
tag.feeds #=> [#<Feed "xkcd">, #<Feed "Dilbert">, ...]
Instance Attribute Summary collapse
-
#client ⇒ Client
readonly
A link to Client.
-
#id ⇒ string
readonly
The ID.
-
#sortid ⇒ string
readonly
A sortable field.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#entries(options = {}) ⇒ Entries
List of entries.
-
#expire! ⇒ Object
Expires the cache.
-
#feeds ⇒ Feed[]
Returns a list of feeds.
-
#initialize(client, options) ⇒ Tag
constructor
A new instance of Tag.
- #to_param ⇒ Object
- #to_s ⇒ Object
Methods included from Utilities
#escape, #kv_map, #slug, #strip_tags
Constructor Details
#initialize(client, options) ⇒ Tag
Returns a new instance of Tag.
34 35 36 37 38 39 |
# File 'lib/greader/tag.rb', line 34 def initialize(client, ) @client = client @options = @id = ['id'] @sortid = ['sortid'] end |
Instance Attribute Details
#client ⇒ Client (readonly)
A link to Client.
32 33 34 |
# File 'lib/greader/tag.rb', line 32 def client @client end |
#id ⇒ string (readonly)
The ID. Also used for Client#tag.
24 25 26 |
# File 'lib/greader/tag.rb', line 24 def id @id end |
#sortid ⇒ string (readonly)
A sortable field.
28 29 30 |
# File 'lib/greader/tag.rb', line 28 def sortid @sortid end |
Instance Method Details
#<=>(other) ⇒ Object
49 50 51 |
# File 'lib/greader/tag.rb', line 49 def <=>(other) sortid <=> other.sortid end |
#entries(options = {}) ⇒ Entries
List of entries.
Options
- limit
-
The number of items (default
20
) - order
-
The order of items;
:desc
is recent first,:asc
is earliest first (default:desc
) - start_time
-
The time (
Time
object) from which to start getting items. Only applicable iforder
is:asc
.
Quirks
The results are cached. If you want to purge the cache, use #expire!.
60 61 62 |
# File 'lib/greader/tag.rb', line 60 def entries(={}) @entries ||= Entries.fetch @client, "stream/contents/#{escape id}" end |
#expire! ⇒ Object
Expires the cache.
66 67 68 |
# File 'lib/greader/tag.rb', line 66 def expire! @entries = nil end |
#feeds ⇒ Feed[]
Returns a list of feeds.
55 56 57 |
# File 'lib/greader/tag.rb', line 55 def feeds @client.feeds.select { |feed| feed..include?(self) } end |
#to_param ⇒ Object
45 46 47 |
# File 'lib/greader/tag.rb', line 45 def to_param slug @id end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/greader/tag.rb', line 41 def to_s @id.split('/').last end |