Class: Nelumba::Comment

Inherits:
Object
  • Object
show all
Includes:
Object
Defined in:
lib/nelumba/comment.rb

Constant Summary

Constants included from Object

Object::USERNAME_REGULAR_EXPRESSION

Instance Attribute Summary collapse

Attributes included from Object

#author, #content, #display_name, #html, #image, #published, #summary, #text, #title, #uid, #updated, #url

Instance Method Summary collapse

Methods included from Object

#mentions, #reply_to, #to_as1, #to_html, #to_json, #to_text

Constructor Details

#initialize(options = {}, &blk) ⇒ Comment

Create a new Comment activity object.

options:

:content      => The body of the comment in HTML.
:author       => A Nelumba::Person that created the object.
:display_name => A natural-language, human-readable and plain-text name
                 for the comment.
:summary      => Natural-language summarization of the comment.
:url          => The canonical url of this comment.
:uid          => The unique id that identifies this comment.
:image        =>
:published    => The Time when this comment was originally published.
:updated      => The Time when this comment was last modified.


21
22
23
# File 'lib/nelumba/comment.rb', line 21

def initialize(options = {}, &blk)
  init(options, &blk)
end

Instance Attribute Details

#in_reply_toObject (readonly)

Holds a collection of Nelumba::Activity’s that this comment is in reply to.



6
7
8
# File 'lib/nelumba/comment.rb', line 6

def in_reply_to
  @in_reply_to
end

Instance Method Details

#init(options = {}, &blk) ⇒ Object



25
26
27
28
29
# File 'lib/nelumba/comment.rb', line 25

def init(options = {}, &blk)
  @in_reply_to  = options[:in_reply_to] || []

  super options
end

#to_hashObject

Returns a Hash representing this comment.



32
33
34
35
36
# File 'lib/nelumba/comment.rb', line 32

def to_hash
  {
    :in_reply_to  => @in_reply_to
  }.merge(super)
end

#to_json_hashObject

Returns a Hash representing this comment with JSON ActivityStreams conventions.



40
41
42
43
44
45
# File 'lib/nelumba/comment.rb', line 40

def to_json_hash
  {
    :objectType   => "comment",
    :in_reply_to  => @in_reply_to
  }.merge(super)
end