Class: AtomFeed::AtomFeedEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/atom_feed/atom_feed_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ AtomFeedEntry

Returns a new instance of AtomFeedEntry.



6
7
8
# File 'lib/atom_feed/atom_feed_entry.rb', line 6

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/atom_feed/atom_feed_entry.rb', line 4

def node
  @node
end

Instance Method Details

#authorsObject

Array of authors (optional).



26
27
28
29
# File 'lib/atom_feed/atom_feed_entry.rb', line 26

def authors
  nodes = @node.xpath("atom:author", ::AtomFeed::NS) || []
  nodes.map { |node| AtomPerson.new(node) }
end

#categoriesObject

categories (optional)



52
53
54
55
# File 'lib/atom_feed/atom_feed_entry.rb', line 52

def categories
  nodes = @node.xpath("atom:category", ::AtomFeed::NS) || []
  nodes.map { |node| AtomCategory.new(node) }
end

#contentObject

Content (optional)



38
39
40
41
42
# File 'lib/atom_feed/atom_feed_entry.rb', line 38

def content
  node = @node.at_xpath("atom:content", ::AtomFeed::NS)
  return nil unless node
  AtomText.new(node)
end

#contributorsObject

contributors (optional)



58
59
60
61
# File 'lib/atom_feed/atom_feed_entry.rb', line 58

def contributors
  nodes = @node.xpath("atom:contributor", ::AtomFeed::NS) || []
  nodes.map { |node| AtomPerson.new(node) }
end

#idObject

Entry id (required).



11
12
13
# File 'lib/atom_feed/atom_feed_entry.rb', line 11

def id
  @node.at_xpath("atom:id", ::AtomFeed::NS).content
end

Array of links (optional).



32
33
34
35
# File 'lib/atom_feed/atom_feed_entry.rb', line 32

def links
  nodes = @node.xpath("atom:link", ::AtomFeed::NS) || []
  nodes.map { |node| AtomLink.new(node) }
end

#publishedObject

Published (optional)



64
65
66
67
68
# File 'lib/atom_feed/atom_feed_entry.rb', line 64

def published
  time = @node.at_xpath("atom:published", ::AtomFeed::NS).try(:content)
  return nil unless time
  Time.parse(time)
end

#rightsObject

rights (optional)



78
79
80
81
82
# File 'lib/atom_feed/atom_feed_entry.rb', line 78

def rights
  node = @node.at_xpath("atom:rights", ::AtomFeed::NS)
  return nil unless node
  AtomText.new(node)
end

#sourceObject

source (optional)



71
72
73
74
75
# File 'lib/atom_feed/atom_feed_entry.rb', line 71

def source
  if node = @node.at_xpath("atom:source", ::AtomFeed::NS)
    AtomFeedEntry.new(node)
  end
end

#summaryObject

Summary (optional)



45
46
47
48
49
# File 'lib/atom_feed/atom_feed_entry.rb', line 45

def summary
  node = @node.at_xpath("atom:summary", ::AtomFeed::NS)
  return nil unless node
  AtomText.new(node)
end

#titleObject

Entry title (required).



16
17
18
# File 'lib/atom_feed/atom_feed_entry.rb', line 16

def title
  @node.at_xpath("atom:title", ::AtomFeed::NS).content
end

#updatedObject

Entry update date (required).



21
22
23
# File 'lib/atom_feed/atom_feed_entry.rb', line 21

def updated
  Time.parse @node.at_xpath("atom:updated", ::AtomFeed::NS).content
end