Class: Lotus::Activity
- Inherits:
-
Object
- Object
- Lotus::Activity
- Defined in:
- lib/lotus/activity.rb
Overview
This class represents an Activity object for an Lotus::Entry.
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Holds an Lotus::Author.
-
#content ⇒ Object
readonly
Holds the content.
-
#content_type ⇒ Object
readonly
Holds the MIME type of the content.
-
#id ⇒ Object
readonly
Holds the id that uniquely identifies this entry.
-
#in_reply_to ⇒ Object
readonly
Holds an array of related Lotus::Entry’s that this entry is a response to.
-
#object ⇒ Object
readonly
The object of this activity.
-
#published ⇒ Object
readonly
Holds the DateTime of when the entry was published originally.
-
#source ⇒ Object
readonly
Holds the source of this entry as an Lotus::Feed.
-
#target ⇒ Object
readonly
The target of the action.
-
#title ⇒ Object
readonly
Holds a String containing the title of the entry.
-
#type ⇒ Object
readonly
The type of object for this activity.
-
#updated ⇒ Object
readonly
Holds the DateTime of when the entry was last modified.
-
#url ⇒ Object
readonly
Holds the url that represents the entry.
-
#verb ⇒ Object
readonly
The action being invoked in this activity.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Activity
constructor
Create a new entry with the given content.
-
#to_atom ⇒ Object
Returns a string containing the Atom representation of this Activity.
-
#to_hash ⇒ Object
Returns a hash of all relevant fields.
Constructor Details
#initialize(options = {}) ⇒ Activity
Create a new entry with the given content.
options:
:object => The object of this activity.
:type => The type of object for this activity.
:target => The target of this activity.
:verb => The action of the activity.
:title => The title of the entry. Defaults: "Untitled"
:actor => An Lotus::Author responsible for generating this entry.
:content => The content of the entry. Defaults: ""
:content_type => The MIME type of the content.
:source => An Lotus::Feed where this Entry originated. This
should be used when an Entry is copied into this feed
from another.
:published => The DateTime depicting when the entry was originally
published.
:updated => The DateTime depicting when the entry was modified.
:url => The canonical url of the entry.
:id => The unique id that identifies this entry.
:activity => The activity this entry represents. Either a single string
denoting what type of object this entry represents, or an
entire Lotus::Activity when a more detailed description is
appropriate.
:in_reply_to => An Lotus::Entry for which this entry is a response.
Or an array of Lotus::Entry's that this entry is a
response to. Use this when this Entry is a reply
to an existing Entry.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/lotus/activity.rb', line 84 def initialize( = {}) @object = [:object] @type = [:type] @target = [:target] @verb = [:verb] @title = [:title] || "Untitled" @actor = [:actor] @content = [:content] || "" @content_type = [:content_type] @source = [:source] @published = [:published] @updated = [:updated] @url = [:url] @id = [:id] unless [:in_reply_to].nil? or [:in_reply_to].is_a?(Array) [:in_reply_to] = [[:in_reply_to]] end @in_reply_to = [:in_reply_to] || [] end |
Instance Attribute Details
#actor ⇒ Object (readonly)
Holds an Lotus::Author.
29 30 31 |
# File 'lib/lotus/activity.rb', line 29 def actor @actor end |
#content ⇒ Object (readonly)
Holds the content.
32 33 34 |
# File 'lib/lotus/activity.rb', line 32 def content @content end |
#content_type ⇒ Object (readonly)
Holds the MIME type of the content.
35 36 37 |
# File 'lib/lotus/activity.rb', line 35 def content_type @content_type end |
#id ⇒ Object (readonly)
Holds the id that uniquely identifies this entry.
38 39 40 |
# File 'lib/lotus/activity.rb', line 38 def id @id end |
#in_reply_to ⇒ Object (readonly)
Holds an array of related Lotus::Entry’s that this entry is a response to.
54 55 56 |
# File 'lib/lotus/activity.rb', line 54 def in_reply_to @in_reply_to end |
#object ⇒ Object (readonly)
The object of this activity.
5 6 7 |
# File 'lib/lotus/activity.rb', line 5 def object @object end |
#published ⇒ Object (readonly)
Holds the DateTime of when the entry was published originally.
47 48 49 |
# File 'lib/lotus/activity.rb', line 47 def published @published end |
#source ⇒ Object (readonly)
Holds the source of this entry as an Lotus::Feed.
44 45 46 |
# File 'lib/lotus/activity.rb', line 44 def source @source end |
#target ⇒ Object (readonly)
The target of the action.
23 24 25 |
# File 'lib/lotus/activity.rb', line 23 def target @target end |
#title ⇒ Object (readonly)
Holds a String containing the title of the entry.
26 27 28 |
# File 'lib/lotus/activity.rb', line 26 def title @title end |
#type ⇒ Object (readonly)
The type of object for this activity.
The field can be a String for uncommon types. Several are standard:
:article, :audio, :bookmark, :comment, :file, :folder, :group,
:list, :note, :person, :photo, :"photo-album", :place, :playlist,
:product, :review, :service, :status, :video
13 14 15 |
# File 'lib/lotus/activity.rb', line 13 def type @type end |
#updated ⇒ Object (readonly)
Holds the DateTime of when the entry was last modified.
50 51 52 |
# File 'lib/lotus/activity.rb', line 50 def updated @updated end |
#url ⇒ Object (readonly)
Holds the url that represents the entry.
41 42 43 |
# File 'lib/lotus/activity.rb', line 41 def url @url end |
#verb ⇒ Object (readonly)
The action being invoked in this activity.
The field can be a String for uncommon verbs. Several are standard:
:favorite, :follow, :like, :"make-friend", :join, :play,
:post, :save, :share, :tag, :update
20 21 22 |
# File 'lib/lotus/activity.rb', line 20 def verb @verb end |
Instance Method Details
#to_atom ⇒ Object
Returns a string containing the Atom representation of this Activity.
128 129 130 131 132 |
# File 'lib/lotus/activity.rb', line 128 def to_atom require 'lotus/atom/entry' Lotus::Atom::Entry.from_canonical(self).to_xml end |
#to_hash ⇒ Object
Returns a hash of all relevant fields.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/lotus/activity.rb', line 107 def to_hash { :source => self.source, :title => self.title, :content => self.content, :content_type => self.content_type, :published => self.published, :updated => self.updated, :url => self.url, :id => self.id, :in_reply_to => self.in_reply_to.dup, :object => self.object, :target => self.target, :actor => self.actor, :verb => self.verb, :type => self.type } end |