Class: Livefyre::Activity
- Inherits:
-
Object
- Object
- Livefyre::Activity
- Defined in:
- lib/livefyre/activity.rb
Overview
Proxy object for an item from a Conversation activity feed
Instance Attribute Summary (collapse)
- - (Object) body
- - (Object) conversation
- - (Object) created_at
- - (Object) id
- - (Object) state
-
- (User) user
Fetch the user that created this record.
Instance Method Summary (collapse)
-
- (Comment) comment
Cast this activity to a Comment.
-
- (Boolean) comment?
private
Test if this activity represented a comment.
-
- (Activity) initialize(client, params = {})
constructor
A new instance of Activity.
Constructor Details
- (Activity) initialize(client, params = {})
A new instance of Activity
5 6 7 8 9 10 11 |
# File 'lib/livefyre/activity.rb', line 5 def initialize(client, params = {}) @client = Livefyre.client @params = params @id = params["activity_id"] @conversation = Conversation.new(@params["lf_conv_id"], @params["article_identifier"]) @created_at = Time.at(@params["created"]) - Time.at(0).utc_offset end |
Instance Attribute Details
- (Object) body
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def body @body end |
- (Object) conversation
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def conversation @conversation end |
- (Object) created_at
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def created_at @created_at end |
- (Object) id
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def id @id end |
- (Object) state
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def state @state end |
- (User) user
Fetch the user that created this record
29 30 31 |
# File 'lib/livefyre/activity.rb', line 29 def user @user end |
Instance Method Details
- (Comment) comment
Cast this activity to a Comment
16 17 18 19 20 21 22 23 24 |
# File 'lib/livefyre/activity.rb', line 16 def comment Comment.new(@params["lf_comment_id"], conversation, :body => @params["body_text"], :user => user, :parent_id => @params["lf_parent_comment_id"], :author_ip => @params["author_ip"], :state => @params["state"] ) end |
- (Boolean) comment?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test if this activity represented a comment
39 40 41 |
# File 'lib/livefyre/activity.rb', line 39 def comment? @params["activity_type"] == "comment-add" end |