Module: FeedAbstractMixins::Atom

Included in:
FeedAbstract::Channel::Atom, FeedAbstract::Item::Atom
Defined in:
lib/feed-abstract/mixins.rb

Overview

Instance methods shared between FeedAbstract::Channel::Atom and FeedAbstract::Item::Atom

Instance Method Summary collapse

Instance Method Details

#authorObject

The authors list as a string, joined with a comma.



48
49
50
51
# File 'lib/feed-abstract/mixins.rb', line 48

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

#authorsObject

An array of author names



39
40
41
42
43
44
45
# File 'lib/feed-abstract/mixins.rb', line 39

def authors
  if self.respond_to?(:channel) && self.channel.generator == 'Twitter'
    return [@source.author.name.content.split(' ')[0]]
  end
  return [] if @source.authors.empty?
  @source.authors.collect{|au| au.name.content}.reject{|au| au == '' || au.match(/^\s+$/)}
end

#categoriesObject

The categories list as an array.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/feed-abstract/mixins.rb', line 54

def categories
  if self.respond_to?(:channel) && self.channel.generator == 'Twitter'
    return @source.title.content.scan(/#([^#\s]+)/).flatten
  end
  return [] if @source.categories.empty? && @source.dc_subjects.empty?
  tmp_cats = []
  tmp_cats << @source.categories.collect{|c| c.term}
  tmp_cats << @source.dc_subjects.collect{|c| c.content}

  tmp_cats.flatten.reject{|c| c == '' || c.match(/^\s+$/)}
end

#categoryObject

The categories list as a string joined with a comma.



67
68
69
70
# File 'lib/feed-abstract/mixins.rb', line 67

def category
  return '' if self.categories.empty?
  self.categories.join(', ')
end

#guidObject

A globally unique ID to this resource, usually (but not always) a URL.



21
22
23
24
# File 'lib/feed-abstract/mixins.rb', line 21

def guid
  return '' if @source.id.nil?
  @source.id.content
end


15
16
17
18
# File 'lib/feed-abstract/mixins.rb', line 15

def link
  return '' if @source.link.nil?
  @source.link.href
end

#rightsObject

Copyright info.



33
34
35
36
# File 'lib/feed-abstract/mixins.rb', line 33

def rights
  return '' if @source.rights.nil?
  @source.rights.content
end

#titleObject



11
12
13
# File 'lib/feed-abstract/mixins.rb', line 11

def title
  @source.title.content
end

#updatedObject

A Time object representing when resource was updated.



27
28
29
30
# File 'lib/feed-abstract/mixins.rb', line 27

def updated
  return '' if @source.updated.nil? && @source.modified.nil?
  (@source.updated.nil?) ? @source.modified.content : @source.updated.content
end