Class: Livefyre::Activity

Inherits:
Object
  • Object
show all
Defined in:
lib/livefyre/activity.rb

Overview

Public: Proxy object for an item from a Conversation activity feed

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/livefyre/activity.rb', line 4

def body
  @body
end

#conversationObject

Returns the value of attribute conversation.



4
5
6
# File 'lib/livefyre/activity.rb', line 4

def conversation
  @conversation
end

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/livefyre/activity.rb', line 4

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/livefyre/activity.rb', line 4

def id
  @id
end

#stateObject

Returns the value of attribute state.



4
5
6
# File 'lib/livefyre/activity.rb', line 4

def state
  @state
end

#userObject

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

#commentObject

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]

Returns:

  • (Boolean)


39
40
41
# File 'lib/livefyre/activity.rb', line 39

def comment?
  @params["activity_type"] == "comment-add"
end