Class: StudioApi::Comment

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

Overview

Comment class

Represents comment attached to published appliance in gallery.

Allows to read id, time, commenter name and text of comment together with attached appliance

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Comment

Returns a new instance of Comment.



10
11
12
13
14
# File 'lib/studio_api/comment.rb', line 10

def initialize hash
  hash.each do |k,v|
    instance_variable_set :"@#{k}", v
  end
end

Instance Attribute Details

#applianceObject (readonly)

Returns the value of attribute appliance.



8
9
10
# File 'lib/studio_api/comment.rb', line 8

def appliance
  @appliance
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/studio_api/comment.rb', line 8

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



8
9
10
# File 'lib/studio_api/comment.rb', line 8

def text
  @text
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'lib/studio_api/comment.rb', line 8

def timestamp
  @timestamp
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/studio_api/comment.rb', line 8

def username
  @username
end

Class Method Details

.parse(appliance, hash) ⇒ Object



16
17
18
# File 'lib/studio_api/comment.rb', line 16

def self.parse(appliance, hash)
  Comment.new hash.merge(:appliance => appliance)
end

Instance Method Details

#reply(text) ⇒ Object

Post reply to comment with text @param text reply content



22
23
24
# File 'lib/studio_api/comment.rb', line 22

def reply text
  appliance.post_comment text, :parent => id
end