Class: FeedAbstract::Channel::RSS
- Inherits:
-
Object
- Object
- FeedAbstract::Channel::RSS
- Includes:
- FeedAbstractMixins::RSS
- Defined in:
- lib/feed-abstract/channel/rss.rb
Instance Attribute Summary collapse
-
#feed ⇒ Object
readonly
Returns the value of attribute feed.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#author ⇒ Object
The author list joined with a comma.
-
#authors ⇒ Object
The authors (a merge of the RSS managingEditor and dc:publisher elements) as an array.
-
#categories ⇒ Object
The category list (a merge of the RSS category and dc:subject elements) as an array.
-
#category ⇒ Object
The category list as a string, joined with a comma.
- #description ⇒ Object (also: #subtitle)
-
#generator ⇒ Object
The generator of this feed as a string.
-
#guid ⇒ Object
A globally unique ID for this feed.
-
#icon ⇒ Object
(also: #logo)
A URL to an icon representing this feed.
-
#initialize(feed) ⇒ RSS
constructor
A new instance of RSS.
- #language ⇒ Object
- #link ⇒ Object
-
#rights ⇒ Object
Copyright info.
- #title ⇒ Object
-
#updated ⇒ Object
A Time object.
Constructor Details
#initialize(feed) ⇒ RSS
Returns a new instance of RSS.
9 10 11 |
# File 'lib/feed-abstract/channel/rss.rb', line 9 def initialize(feed) @feed = @source = feed end |
Instance Attribute Details
#feed ⇒ Object (readonly)
Returns the value of attribute feed.
7 8 9 |
# File 'lib/feed-abstract/channel/rss.rb', line 7 def feed @feed end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/feed-abstract/channel/rss.rb', line 7 def source @source end |
Instance Method Details
#author ⇒ Object
The author list joined with a comma.
70 71 72 73 |
# File 'lib/feed-abstract/channel/rss.rb', line 70 def return '' if self..empty? self..join(', ') end |
#authors ⇒ Object
The authors (a merge of the RSS managingEditor and dc:publisher elements) as an array.
64 65 66 67 |
# File 'lib/feed-abstract/channel/rss.rb', line 64 def return [] if @feed.channel.managingEditor.nil? && @feed.channel.dc_publishers.empty? [@feed.channel.managingEditor, ((@feed.channel.dc_publishers.empty?) ? nil : @feed.channel.dc_publishers.collect{|dcp| dcp.content})].flatten.uniq.compact.reject{|au| au == '' || au.match(/^\s+$/)} end |
#categories ⇒ Object
The category list (a merge of the RSS category and dc:subject elements) as an array.
76 77 78 79 |
# File 'lib/feed-abstract/channel/rss.rb', line 76 def categories return [] if @feed.channel.categories.empty? && @feed.channel.dc_subjects.empty? [@feed.channel.categories, ((@feed.channel.dc_subjects.empty?) ? nil : @feed.channel.dc_subjects)].flatten.uniq.compact.collect{|c| c.content}.reject{|c| c == '' || c.match(/^\s+$/)} end |
#category ⇒ Object
The category list as a string, joined with a comma.
82 83 84 85 |
# File 'lib/feed-abstract/channel/rss.rb', line 82 def category return '' if self.categories.empty? self.categories.join(', ') end |
#description ⇒ Object Also known as: subtitle
22 23 24 |
# File 'lib/feed-abstract/channel/rss.rb', line 22 def description @feed.channel.description end |
#generator ⇒ Object
The generator of this feed as a string. Sometimes a URL, sometimes a string (e.g. the application name). We will “sniff” out the generator for some feed sources - wordpress, delicious, twitter, etc.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/feed-abstract/channel/rss.rb', line 28 def generator if ! @feed.channel.generator.nil? && @feed.channel.generator.match(/wordpress\.org/i) return 'WordPress' elsif ! @feed.channel.link.nil? && @feed.channel.link.match(/www\.delicious\.com/i) return 'Delicious' elsif ! @feed.channel.link.nil? && @feed.channel.link.match(/https?:\/\/.*\.?twitter\.com/i) return 'Twitter' end return '' if @feed.channel.generator.nil? @feed.channel.generator end |
#guid ⇒ Object
A globally unique ID for this feed. A URL in this case.
58 59 60 61 |
# File 'lib/feed-abstract/channel/rss.rb', line 58 def guid return '' if @feed.channel.link.nil? @feed.channel.link end |
#icon ⇒ Object Also known as: logo
A URL to an icon representing this feed.
88 89 90 91 |
# File 'lib/feed-abstract/channel/rss.rb', line 88 def icon return '' if @feed.channel.image.nil? @feed.channel.image.url end |
#language ⇒ Object
17 18 19 20 |
# File 'lib/feed-abstract/channel/rss.rb', line 17 def language return '' if @feed.channel.language.nil? @feed.channel.language end |
#link ⇒ Object
40 41 42 43 |
# File 'lib/feed-abstract/channel/rss.rb', line 40 def link return '' if @feed.channel.link.nil? @feed.channel.link end |
#rights ⇒ Object
Copyright info.
46 47 48 49 |
# File 'lib/feed-abstract/channel/rss.rb', line 46 def rights return '' if @feed.channel.copyright.nil? && @feed.channel.dc_rights.nil? [@feed.channel.copyright,@feed.channel.dc_rights].compact.join(' ') end |
#title ⇒ Object
13 14 15 |
# File 'lib/feed-abstract/channel/rss.rb', line 13 def title @feed.channel.title end |
#updated ⇒ Object
A Time object.
52 53 54 55 |
# File 'lib/feed-abstract/channel/rss.rb', line 52 def updated return '' if @feed.channel.lastBuildDate.nil? && @feed.channel.pubDate.nil? (@feed.channel.lastBuildDate.nil?) ? @feed.channel.pubDate : @feed.channel.lastBuildDate end |