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

- (Comment) initialize(hash)

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

- (Object) appliance (readonly)

Returns the value of attribute appliance



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

def appliance
  @appliance
end

- (Object) id (readonly)

Returns the value of attribute id



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

def id
  @id
end

- (Object) text (readonly)

Returns the value of attribute text



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

def text
  @text
end

- (Object) timestamp (readonly)

Returns the value of attribute timestamp



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

def timestamp
  @timestamp
end

- (Object) username (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

+ (Object) parse(appliance, hash)



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

- (Object) reply(text)

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