Class: Lotus::Feed
- Inherits:
-
Object
- Object
- Lotus::Feed
- Defined in:
- lib/lotus/feed.rb
Overview
This class represents a Lotus::Feed object.
Instance Attribute Summary collapse
-
#authors ⇒ Object
readonly
Holds the list of authors as Lotus::Author responsible for this feed.
-
#categories ⇒ Object
readonly
Holds the list of categories for this feed as Lotus::Category.
-
#contributors ⇒ Object
readonly
Holds the list of contributors, if any, that are involved in this feed as Lotus::Author.
-
#entries ⇒ Object
readonly
Holds the list of entries as Lotus::Activity contained within this feed.
-
#generator ⇒ Object
readonly
Holds the generator for this content as an Lotus::Generator.
-
#hubs ⇒ Object
readonly
Holds the list of hubs that are available to manage subscriptions to this feed.
-
#icon ⇒ Object
readonly
Holds the URL for the icon representing this feed.
-
#id ⇒ Object
readonly
Holds the id that uniquely represents this feed.
-
#links ⇒ Object
readonly
Holds links to other resources as an array of Lotus::Link.
-
#logo ⇒ Object
readonly
Holds the URL for the logo representing this feed.
-
#published ⇒ Object
readonly
Holds the DateTime when this feed was originally created.
-
#rights ⇒ Object
readonly
Holds human-readable information about the content rights of the entries in the feed without an explicit rights field of their own.
-
#salmon_url ⇒ Object
readonly
Holds the salmon url that handles notifications for this feed.
-
#subtitle ⇒ Object
readonly
Holds the subtitle for this feed.
-
#subtitle_type ⇒ Object
readonly
Holds the content-type for the subtitle.
-
#title ⇒ Object
readonly
Holds the title for this feed.
-
#title_type ⇒ Object
readonly
Holds the content-type for the title.
-
#updated ⇒ Object
readonly
Holds the DateTime when this feed was last modified.
-
#url ⇒ Object
readonly
Holds the url that represents this feed.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Feed
constructor
Creates a new representation of a feed.
-
#to_atom ⇒ Object
Returns a string containing an Atom representation of the feed.
-
#to_hash ⇒ Object
Returns a hash of the properties of the feed.
-
#to_link(options = {}) ⇒ Object
Yields a Lotus::Link to this feed.
Constructor Details
#initialize(options = {}) ⇒ Feed
Creates a new representation of a feed.
options:
id => The unique identifier for this feed.
url => The url that represents this feed.
title => The title for this feed. Defaults: "Untitled"
title_type => The content type for the title.
subtitle => The subtitle for this feed.
subtitle_type => The content type for the subtitle.
authors => The list of Lotus::Author's for this feed.
Defaults: []
contributors => The list of Lotus::Author's that contributed to this
feed. Defaults: []
entries => The list of Lotus::Activity's for this feed.
Defaults: []
icon => The url of the icon that represents this feed. It
should have an aspect ratio of 1 horizontal to 1
vertical and optimized for presentation at a
small size.
logo => The url of the logo that represents this feed. It
should have an aspect ratio of 2 horizontal to 1
vertical.
categories => An array of Lotus::Category's that describe how to
categorize and describe the content of the feed.
Defaults: []
rights => A String depicting the rights of entries without
explicit rights of their own. SHOULD NOT be machine
interpreted.
updated => The DateTime representing when this feed was last
modified.
published => The DateTime representing when this feed was originally
published.
salmon_url => The url of the salmon endpoint, if one exists, for this
feed.
links => An array of Lotus::Link that adds relations to other
resources.
generator => A Lotus::Generator representing the agent
responsible for generating this feed.
Usage:
= Lotus::Author.new(:name => "Kelly")
feed = Lotus::Feed.new(:title => "My Feed",
:id => "1",
:url => "http://example.com/feeds/1",
:authors => [])
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/lotus/feed.rb', line 120 def initialize( = {}) @id = [:id] @url = [:url] @icon = [:icon] @logo = [:logo] @rights = [:rights] @title = [:title] || "Untitled" @title_type = [:title_type] @subtitle = [:subtitle] @subtitle_type = [:subtitle_type] @authors = [:authors] || [] @categories = [:categories] || [] @contributors = [:contributors] || [] @entries = [:entries] || [] @updated = [:updated] @published = [:published] @salmon_url = [:salmon_url] @hubs = [:hubs] || [] @generator = [:generator] end |
Instance Attribute Details
#authors ⇒ Object (readonly)
Holds the list of authors as Lotus::Author responsible for this feed.
58 59 60 |
# File 'lib/lotus/feed.rb', line 58 def @authors end |
#categories ⇒ Object (readonly)
Holds the list of categories for this feed as Lotus::Category.
19 20 21 |
# File 'lib/lotus/feed.rb', line 19 def categories @categories end |
#contributors ⇒ Object (readonly)
Holds the list of contributors, if any, that are involved in this feed as Lotus::Author.
49 50 51 |
# File 'lib/lotus/feed.rb', line 49 def contributors @contributors end |
#entries ⇒ Object (readonly)
Holds the list of entries as Lotus::Activity contained within this feed.
61 62 63 |
# File 'lib/lotus/feed.rb', line 61 def entries @entries end |
#generator ⇒ Object (readonly)
Holds the generator for this content as an Lotus::Generator.
45 46 47 |
# File 'lib/lotus/feed.rb', line 45 def generator @generator end |
#hubs ⇒ Object (readonly)
Holds the list of hubs that are available to manage subscriptions to this feed.
65 66 67 |
# File 'lib/lotus/feed.rb', line 65 def hubs @hubs end |
#icon ⇒ Object (readonly)
Holds the URL for the icon representing this feed.
39 40 41 |
# File 'lib/lotus/feed.rb', line 39 def icon @icon end |
#id ⇒ Object (readonly)
Holds the id that uniquely represents this feed.
13 14 15 |
# File 'lib/lotus/feed.rb', line 13 def id @id end |
#links ⇒ Object (readonly)
Holds links to other resources as an array of Lotus::Link
71 72 73 |
# File 'lib/lotus/feed.rb', line 71 def links @links end |
#logo ⇒ Object (readonly)
Holds the URL for the logo representing this feed.
42 43 44 |
# File 'lib/lotus/feed.rb', line 42 def logo @logo end |
#published ⇒ Object (readonly)
Holds the DateTime when this feed was originally created.
52 53 54 |
# File 'lib/lotus/feed.rb', line 52 def published @published end |
#rights ⇒ Object (readonly)
Holds human-readable information about the content rights of the entries in the feed without an explicit rights field of their own. SHOULD NOT be machine interpreted.
24 25 26 |
# File 'lib/lotus/feed.rb', line 24 def rights @rights end |
#salmon_url ⇒ Object (readonly)
Holds the salmon url that handles notifications for this feed.
68 69 70 |
# File 'lib/lotus/feed.rb', line 68 def salmon_url @salmon_url end |
#subtitle ⇒ Object (readonly)
Holds the subtitle for this feed.
33 34 35 |
# File 'lib/lotus/feed.rb', line 33 def subtitle @subtitle end |
#subtitle_type ⇒ Object (readonly)
Holds the content-type for the subtitle.
36 37 38 |
# File 'lib/lotus/feed.rb', line 36 def subtitle_type @subtitle_type end |
#title ⇒ Object (readonly)
Holds the title for this feed.
27 28 29 |
# File 'lib/lotus/feed.rb', line 27 def title @title end |
#title_type ⇒ Object (readonly)
Holds the content-type for the title.
30 31 32 |
# File 'lib/lotus/feed.rb', line 30 def title_type @title_type end |
#updated ⇒ Object (readonly)
Holds the DateTime when this feed was last modified.
55 56 57 |
# File 'lib/lotus/feed.rb', line 55 def updated @updated end |
#url ⇒ Object (readonly)
Holds the url that represents this feed.
16 17 18 |
# File 'lib/lotus/feed.rb', line 16 def url @url end |
Instance Method Details
#to_atom ⇒ Object
Returns a string containing an Atom representation of the feed.
184 185 186 187 188 |
# File 'lib/lotus/feed.rb', line 184 def to_atom require 'lotus/atom/feed' Lotus::Atom::Feed.from_canonical(self).to_xml end |
#to_hash ⇒ Object
Returns a hash of the properties of the feed.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/lotus/feed.rb', line 160 def to_hash { :id => self.id, :url => self.url, :hubs => self.hubs.dup, :icon => self.icon, :logo => self.logo, :rights => self.rights, :title => self.title, :title_type => self.title_type, :subtitle => self.subtitle, :subtitle_type => self.subtitle_type, :authors => self..dup, :categories => self.categories.dup, :contributors => self.contributors.dup, :entries => self.entries.dup, :updated => self.updated, :salmon_url => self.salmon_url, :published => self.published, :generator => self.generator } end |
#to_link(options = {}) ⇒ Object
Yields a Lotus::Link to this feed.
options: Can override Lotus::Link properties, such as rel.
Usage:
feed = Lotus::Feed.new(:title => "Foo", :url => "http://example.com")
feed.to_link(:rel => "alternate", :title => "Foo's Feed")
Generates a link with:
<Lotus::Link rel="alternate" title="Foo's Feed" url="http://example.com">
152 153 154 155 156 157 |
# File 'lib/lotus/feed.rb', line 152 def to_link( = {}) = { :title => self.title, :href => self.url }.merge() Lotus::Link.new() end |