Class: FeedAbstract::Channel::RSS

Inherits:
Object
  • Object
show all
Includes:
FeedAbstractMixins::RSS
Defined in:
lib/feed-abstract/channel/rss.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#feedObject (readonly)

Returns the value of attribute feed.



7
8
9
# File 'lib/feed-abstract/channel/rss.rb', line 7

def feed
  @feed
end

#sourceObject (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

#authorObject

The author list joined with a comma.



70
71
72
73
# File 'lib/feed-abstract/channel/rss.rb', line 70

def author
  return '' if self.authors.empty?
  self.authors.join(', ')
end

#authorsObject

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 authors
  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

#categoriesObject

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

#categoryObject

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

#descriptionObject Also known as: subtitle



22
23
24
# File 'lib/feed-abstract/channel/rss.rb', line 22

def description
  @feed.channel.description
end

#generatorObject

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.match(/www\.delicious\.com/i)
    return 'Delicious'
  elsif @feed.channel.link.match(/https?:\/\/.*\.?twitter\.com/i)
    return 'Twitter'
  end
  return '' if @feed.channel.generator.nil?
  @feed.channel.generator
end

#guidObject

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

#iconObject 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

#languageObject



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


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

#rightsObject

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

#titleObject



13
14
15
# File 'lib/feed-abstract/channel/rss.rb', line 13

def title
  @feed.channel.title
end

#updatedObject

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