Class: FeedAbstract::Item::RSS
- Inherits:
-
Object
- Object
- FeedAbstract::Item::RSS
- Includes:
- FeedAbstractMixins::RSS
- Defined in:
- lib/feed-abstract/item/rss.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#author ⇒ Object
The author list as a string, joined with a comma.
-
#authors ⇒ Object
The author list (a merge of the RSS author and dc:creator elements) as an array.
-
#categories ⇒ Object
The category list as an array.
-
#category ⇒ Object
The category list as a string, joined with a comma.
-
#content ⇒ Object
The full content of this item, theoretically.
-
#contributor ⇒ Object
The contributor list as a string joined with a comma.
-
#contributors ⇒ Object
The contributors (parsed from the dc:contributor element) as an array.
-
#guid ⇒ Object
A globally unique id.
-
#initialize(item, channel) ⇒ RSS
constructor
A new instance of RSS.
- #link ⇒ Object
-
#rights ⇒ Object
Copyright info.
- #summary ⇒ Object
- #title ⇒ Object
- #updated ⇒ Object (also: #published)
Constructor Details
#initialize(item, channel) ⇒ RSS
Returns a new instance of RSS.
10 11 12 13 |
# File 'lib/feed-abstract/item/rss.rb', line 10 def initialize(item,channel) @item = @source = item @channel = channel end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
8 9 10 |
# File 'lib/feed-abstract/item/rss.rb', line 8 def channel @channel end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
8 9 10 |
# File 'lib/feed-abstract/item/rss.rb', line 8 def item @item end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/feed-abstract/item/rss.rb', line 8 def source @source end |
Instance Method Details
#author ⇒ Object
The author list as a string, joined with a comma.
44 45 46 |
# File 'lib/feed-abstract/item/rss.rb', line 44 def (self..empty?) ? '' : self..join(', ') end |
#authors ⇒ Object
The author list (a merge of the RSS author and dc:creator elements) as an array.
36 37 38 39 40 41 |
# File 'lib/feed-abstract/item/rss.rb', line 36 def if self.channel.generator == 'Twitter' return [@item.title.split(':')[0]] end [@item., ((@item.dc_creators.empty?) ? nil : @item.dc_creators.collect{|c| c.content})].flatten.uniq.compact.reject{|au| au == '' || au.match(/^\s+$/)} end |
#categories ⇒ Object
The category list as an array.
59 60 61 62 63 64 65 |
# File 'lib/feed-abstract/item/rss.rb', line 59 def categories if self.channel.generator == 'Twitter' return @item.title.scan(/#([^#\s]+)/).flatten end return [] if @item.categories.empty? @item.categories.collect{|c| c.content}.reject{|c| c == '' || c.match(/^\s+$/)} end |
#category ⇒ Object
The category list as a string, joined with a comma.
68 69 70 71 72 73 74 |
# File 'lib/feed-abstract/item/rss.rb', line 68 def category if self.channel.generator == 'Twitter' return self.categories.join(', ') end return '' if @item.categories.empty? @item.categories.collect{|c| c.content}.join(', ') end |
#content ⇒ Object
The full content of this item, theoretically.
21 22 23 24 |
# File 'lib/feed-abstract/item/rss.rb', line 21 def content return '' if @item.content_encoded.nil? @item.content_encoded end |
#contributor ⇒ Object
The contributor list as a string joined with a comma.
54 55 56 |
# File 'lib/feed-abstract/item/rss.rb', line 54 def contributor (self.contributors.empty?) ? '' : self.contributors.join(', ') end |
#contributors ⇒ Object
The contributors (parsed from the dc:contributor element) as an array.
49 50 51 |
# File 'lib/feed-abstract/item/rss.rb', line 49 def contributors (@item.dc_contributors.empty?) ? [] : @item.dc_contributors.reject{|au| au == '' || au.match(/^\s+$/)} end |
#guid ⇒ Object
A globally unique id.
87 88 89 90 |
# File 'lib/feed-abstract/item/rss.rb', line 87 def guid return '' if @item.guid.nil? @item.guid.content end |
#link ⇒ Object
31 32 33 |
# File 'lib/feed-abstract/item/rss.rb', line 31 def link @item.link end |
#rights ⇒ Object
Copyright info.
77 78 79 |
# File 'lib/feed-abstract/item/rss.rb', line 77 def rights (@item.dc_rights.nil?) ? '' : @item.dc_rights end |
#summary ⇒ Object
26 27 28 29 |
# File 'lib/feed-abstract/item/rss.rb', line 26 def summary return '' if @item.description.nil? @item.description end |
#title ⇒ Object
15 16 17 18 |
# File 'lib/feed-abstract/item/rss.rb', line 15 def title return '' if @item.title.nil? @item.title end |
#updated ⇒ Object Also known as: published
81 82 83 |
# File 'lib/feed-abstract/item/rss.rb', line 81 def updated (@item.pubDate.nil?) ? '' : @item.pubDate end |