Class: Superfeedr::Entry

Inherits:
Blather::Stanza::PubSubItem
  • Object
show all
Defined in:
lib/superfeedr/entry.rb

Defined Under Namespace

Classes: Author, Link

Constant Summary collapse

NS =
'http://www.w3.org/2005/Atom'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(node) ⇒ Object



5
6
7
8
9
10
# File 'lib/superfeedr/entry.rb', line 5

def self.parse(node)
  node.find('//ns:event/ns:items/ns2:item', :ns => Blather::Stanza::PubSub::Event.registered_ns,
                                            :ns2 => Blather::Stanza::PubSub.registered_ns).map do |item|
    Entry.new('item').inherit(item)
  end
end

Instance Method Details

#authorsObject



50
51
52
# File 'lib/superfeedr/entry.rb', line 50

def authors
  self.entry.find('ns:author', :ns => NS).map { |l| Author.new.inherit(l) }
end

#categoriesObject



42
43
44
# File 'lib/superfeedr/entry.rb', line 42

def categories
  self.entry.find('ns:category', :ns => NS).map { |cat| cat[:term] }
end

#chunkObject



16
17
18
# File 'lib/superfeedr/entry.rb', line 16

def chunk
  self[:chunk].to_i
end

#chunksObject



12
13
14
# File 'lib/superfeedr/entry.rb', line 12

def chunks
  self[:chunks].to_i
end

#contentObject



34
35
36
# File 'lib/superfeedr/entry.rb', line 34

def content
  self.entry.content_from 'ns:content', :ns => NS
end

#entryObject



54
55
56
# File 'lib/superfeedr/entry.rb', line 54

def entry
  Blather::XMPPNode.import(super)
end

#idObject



20
21
22
# File 'lib/superfeedr/entry.rb', line 20

def id
  self.entry.content_from 'ns:id', :ns => NS
end


46
47
48
# File 'lib/superfeedr/entry.rb', line 46

def links
  self.entry.find('ns:link', :ns => NS).map { |l| Link.new.inherit(l) }
end

#publishedObject



28
29
30
31
32
# File 'lib/superfeedr/entry.rb', line 28

def published
  if published = self.entry.content_from('ns:published', :ns => NS)
    DateTime.parse published
  end
end

#summaryObject



38
39
40
# File 'lib/superfeedr/entry.rb', line 38

def summary
  self.entry.content_from 'ns:summary', :ns => NS
end

#titleObject



24
25
26
# File 'lib/superfeedr/entry.rb', line 24

def title
  self.entry.content_from 'ns:title', :ns => NS
end