Class: Livefyre::Activity
- Inherits:
-
Object
- Object
- Livefyre::Activity
- Defined in:
- lib/livefyre/activity.rb
Overview
Public: Proxy object for an item from a Conversation activity feed
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#conversation ⇒ Object
Returns the value of attribute conversation.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#state ⇒ Object
Returns the value of attribute state.
-
#user ⇒ Object
Public: Fetch the user that created this record.
Instance Method Summary collapse
-
#comment ⇒ Object
Public: Cast this activity to a Comment.
-
#comment? ⇒ Boolean
Internal: Test if this activity represented a comment.
-
#initialize(client, params = {}) ⇒ Activity
constructor
A new instance of Activity.
Constructor Details
#initialize(client, params = {}) ⇒ Activity
Returns 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
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def body @body end |
#conversation ⇒ Object
Returns the value of attribute conversation.
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def conversation @conversation end |
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def id @id end |
#state ⇒ Object
Returns the value of attribute state.
4 5 6 |
# File 'lib/livefyre/activity.rb', line 4 def state @state end |
#user ⇒ Object
Public: Fetch the user that created this record
Returns [User]
29 30 31 |
# File 'lib/livefyre/activity.rb', line 29 def user @user end |
Instance Method Details
#comment ⇒ Object
Public: Cast this activity to a Comment
Return [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 |
#comment? ⇒ Boolean
Internal: Test if this activity represented a comment
Returns [Boolean]
39 40 41 |
# File 'lib/livefyre/activity.rb', line 39 def comment? @params["activity_type"] == "comment-add" end |