Class: Nelumba::Feed
- Inherits:
-
Collection
- Object
- Collection
- Nelumba::Feed
- Defined in:
- lib/nelumba/feed.rb
Overview
This class represents a Nelumba::Feed object.
Constant Summary
Constants included from Object
Object::USERNAME_REGULAR_EXPRESSION
Instance Attribute Summary collapse
-
#authors ⇒ Object
readonly
Holds the list of authors as Nelumba::Person responsible for this feed.
-
#categories ⇒ Object
readonly
Holds the list of categories for this feed as Nelumba::Category.
-
#contributors ⇒ Object
readonly
Holds the list of contributors, if any, that are involved in this feed as Nelumba::Person.
-
#generator ⇒ Object
readonly
Holds the generator for this content as an Nelumba::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.
-
#links ⇒ Object
readonly
Holds links to other resources as an array of Nelumba::Link.
-
#logo ⇒ Object
readonly
Holds the URL for the logo representing this feed.
-
#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.
Attributes inherited from Collection
Attributes included from Object
#author, #content, #display_name, #html, #image, #published, #summary, #text, #uid, #updated, #url
Instance Method Summary collapse
- #init(options = {}) ⇒ Object
-
#initialize(options = {}, &blk) ⇒ 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_json_hash ⇒ Object
-
#to_link(options = {}) ⇒ Object
Yields a Nelumba::Link to this feed.
Methods included from Object
#mentions, #reply_to, #to_as1, #to_html, #to_json, #to_text
Constructor Details
#initialize(options = {}, &blk) ⇒ Feed
Creates a new representation of a feed.
options:
uid => 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 Nelumba::Person's for this feed.
Defaults: []
contributors => The list of Nelumba::Person's that contributed to this
feed. Defaults: []
items => The list of Nelumba::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 Nelumba::Category's that describe how to
categorize and describe the content of the feed.
Defaults: []
rights => A String depicting the rights of items 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 Nelumba::Link that adds relations to other
resources.
generator => A Nelumba::Generator representing the agent
responsible for generating this feed.
Usage:
= Nelumba::Person.new(:name => "Kelly")
feed = Nelumba::Feed.new(:title => "My Feed",
:uid => "1",
:url => "http://example.com/feeds/1",
:authors => [])
100 101 102 |
# File 'lib/nelumba/feed.rb', line 100 def initialize( = {}, &blk) init(, &blk) end |
Instance Attribute Details
#authors ⇒ Object (readonly)
Holds the list of authors as Nelumba::Person responsible for this feed.
41 42 43 |
# File 'lib/nelumba/feed.rb', line 41 def @authors end |
#categories ⇒ Object (readonly)
Holds the list of categories for this feed as Nelumba::Category.
8 9 10 |
# File 'lib/nelumba/feed.rb', line 8 def categories @categories end |
#contributors ⇒ Object (readonly)
Holds the list of contributors, if any, that are involved in this feed as Nelumba::Person.
38 39 40 |
# File 'lib/nelumba/feed.rb', line 38 def contributors @contributors end |
#generator ⇒ Object (readonly)
Holds the generator for this content as an Nelumba::Generator.
34 35 36 |
# File 'lib/nelumba/feed.rb', line 34 def generator @generator end |
#hubs ⇒ Object (readonly)
Holds the list of hubs that are available to manage subscriptions to this feed.
45 46 47 |
# File 'lib/nelumba/feed.rb', line 45 def hubs @hubs end |
#icon ⇒ Object (readonly)
Holds the URL for the icon representing this feed.
28 29 30 |
# File 'lib/nelumba/feed.rb', line 28 def icon @icon end |
#links ⇒ Object (readonly)
Holds links to other resources as an array of Nelumba::Link
51 52 53 |
# File 'lib/nelumba/feed.rb', line 51 def links @links end |
#logo ⇒ Object (readonly)
Holds the URL for the logo representing this feed.
31 32 33 |
# File 'lib/nelumba/feed.rb', line 31 def logo @logo 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.
13 14 15 |
# File 'lib/nelumba/feed.rb', line 13 def rights @rights end |
#salmon_url ⇒ Object (readonly)
Holds the salmon url that handles notifications for this feed.
48 49 50 |
# File 'lib/nelumba/feed.rb', line 48 def salmon_url @salmon_url end |
#subtitle ⇒ Object (readonly)
Holds the subtitle for this feed.
22 23 24 |
# File 'lib/nelumba/feed.rb', line 22 def subtitle @subtitle end |
#subtitle_type ⇒ Object (readonly)
Holds the content-type for the subtitle.
25 26 27 |
# File 'lib/nelumba/feed.rb', line 25 def subtitle_type @subtitle_type end |
#title ⇒ Object (readonly)
Holds the title for this feed.
16 17 18 |
# File 'lib/nelumba/feed.rb', line 16 def title @title end |
#title_type ⇒ Object (readonly)
Holds the content-type for the title.
19 20 21 |
# File 'lib/nelumba/feed.rb', line 19 def title_type @title_type end |
Instance Method Details
#init(options = {}) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/nelumba/feed.rb', line 104 def init( = {}) super @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] || [] @salmon_url = [:salmon_url] @hubs = [:hubs] || [] @generator = [:generator] end |
#to_atom ⇒ Object
Returns a string containing an Atom representation of the feed.
167 168 169 170 171 |
# File 'lib/nelumba/feed.rb', line 167 def to_atom require 'nelumba/atom/feed' Nelumba::Atom::Feed.from_canonical(self).to_xml end |
#to_hash ⇒ Object
Returns a hash of the properties of the feed.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/nelumba/feed.rb', line 141 def to_hash { :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, :updated => self.updated, :salmon_url => self.salmon_url, :published => self.published, :generator => self.generator }.merge(super) end |
#to_json_hash ⇒ Object
161 162 163 164 |
# File 'lib/nelumba/feed.rb', line 161 def to_json_hash { }.merge(super) end |
#to_link(options = {}) ⇒ Object
Yields a Nelumba::Link to this feed.
options: Can override Nelumba::Link properties, such as rel.
Usage:
feed = Nelumba::Feed.new(:title => "Foo", :url => "http://example.com")
feed.to_link(:rel => "alternate", :title => "Foo's Feed")
Generates a link with:
<Nelumba::Link rel="alternate" title="Foo's Feed" url="http://example.com">
133 134 135 136 137 138 |
# File 'lib/nelumba/feed.rb', line 133 def to_link( = {}) = { :title => self.title, :href => self.url }.merge() Nelumba::Link.new() end |