Class: Atom::Entry
- Inherits:
-
Object
- Object
- Atom::Entry
- Extended by:
- Forwardable
- Includes:
- SimpleExtensions, Xml::Parseable
- Defined in:
- lib/atom.rb
Overview
Represents an Entry as defined by the Atom Syndication Format specification.
An Entry represents an individual entry within a Feed.
Parsing
An Entry can be parsed using the Entry.load_entry method. This method accepts a String containing a valid atom entry document, an IO object, or an URI to a valid atom entry document. For example:
# Using a File
entry = Entry.load_entry(File.open("/path/to/myfeedentry.atom"))
# Using a URL
Entry = Entry.load_entry(URI.parse("http://example.org/afeedentry.atom"))
The document must contain a stand alone entry element as described in the Atom Syndication Format.
Encoding
A Entry can be converted to XML using, the to_xml method that returns a valid atom entry document in a String.
Attributes
An entry has the following attributes:
id
-
A unique id for the entry.
updated
-
The Time the entry was updated.
published
-
The Time the entry was published.
title
-
The title of the entry.
summary
-
A short textual summary of the item.
authors
-
An array of Atom::Person objects that are authors of this entry.
contributors
-
An array of Atom::Person objects that are contributors to this entry.
rights
-
A string describing the rights associated with this entry.
links
-
An array of Atom:Link objects. (This is actually an Atom::Links array which is an Array with some sugar).
source
-
Metadata of a feed that was the source of this item, for feed aggregators, etc.
categories
-
Array of Atom::Categories.
content
-
The content of the entry. This will be one of Atom::Content::Text, Atom::Content:Html or Atom::Content::Xhtml.
References
See also www.atomenabled.org/developers/syndication/atom-format-spec.php#element.entry for more detailed definitions of the attributes.
Instance Attribute Summary
Attributes included from SimpleExtensions
Instance Method Summary collapse
-
#initialize(o = {}) {|_self| ... } ⇒ Entry
constructor
Initialize an Entry.
-
#reload! ⇒ Object
Reload the Entry by fetching the self link.
Methods included from SimpleExtensions
Constructor Details
#initialize(o = {}) {|_self| ... } ⇒ Entry
Initialize an Entry.
This will also yield itself, so an Entry can be constructed like this:
entry = Entry.new do |entry|
entry.title = "My Cool entry"
end
o
-
An XML Reader or a Hash of attributes.
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/atom.rb', line 538 def initialize(o = {}) @links = Links.new @authors = [] @contributors = [] @categories = [] case o when XML::Reader if current_node_is?(o, 'entry', Atom::NAMESPACE) || next_node_is?(o, 'entry', Atom::NAMESPACE) o.read parse(o) else raise ArgumentError, "Entry created with node other than atom:entry: #{o.name}" end when Hash o.each do |k,v| send("#{k.to_s}=", v) end end yield(self) if block_given? end |
Instance Method Details
#reload! ⇒ Object
Reload the Entry by fetching the self link.
562 563 564 565 566 |
# File 'lib/atom.rb', line 562 def reload! if links.self Entry.load_entry(URI.parse(links.self.href)) end end |