Class: ReplTalk::ReplComment

Inherits:
Object
  • Object
show all
Defined in:
lib/repltalk/structures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, comment) ⇒ ReplComment

Returns a new instance of ReplComment.



87
88
89
90
91
92
93
94
95
# File 'lib/repltalk/structures.rb', line 87

def initialize(client, comment)
	@client = client

	@id = comment["id"]
	@content = comment["body"]
	@author = comment["user"] == nil ? nil : User.new(@client, comment["user"])
	@repl = comment["repl"] == nil ? nil : Repl.new(@client, comment["repl"])
	@replies = comment["replies"] == nil ? nil : comment["replies"].map { |c| ReplComment.new(@client, c) }
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



85
86
87
# File 'lib/repltalk/structures.rb', line 85

def author
  @author
end

#contentObject (readonly)

Returns the value of attribute content.



85
86
87
# File 'lib/repltalk/structures.rb', line 85

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id.



85
86
87
# File 'lib/repltalk/structures.rb', line 85

def id
  @id
end

#replObject (readonly)

Returns the value of attribute repl.



85
86
87
# File 'lib/repltalk/structures.rb', line 85

def repl
  @repl
end

#repliesObject (readonly)

Returns the value of attribute replies.



85
86
87
# File 'lib/repltalk/structures.rb', line 85

def replies
  @replies
end

Instance Method Details

#create_comment(content) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/repltalk/structures.rb', line 97

def create_comment(content)
	c = @client.graphql(
		"ReplViewCreateReplCommentReply",
		GQL::Mutations::REPLY_REPL_COMMENT,
		input: {
			replCommentId: @id,
			body: content
		}
	)
	ReplComment.new(@client, c["createReplCommentReply"])
end

#deleteObject



121
122
123
124
125
126
127
128
# File 'lib/repltalk/structures.rb', line 121

def delete
	@client.graphql(
		"ReplViewCommentsDeleteReplComment",
		GQL::Mutations::DELETE_REPL_COMMENT,
		id: @id
	)
	nil
end

#edit(content) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
# File 'lib/repltalk/structures.rb', line 109

def edit(content)
	c = @client.graphql(
		"ReplViewCommentsUpdateReplComment",
		GQL::Mutations::EDIT_REPL_COMMENT,
		input: {
			id: @id,
			body: content
		}
	)
	ReplComment.new(@client, c["updateReplComment"])
end

#to_sObject



130
131
132
# File 'lib/repltalk/structures.rb', line 130

def to_s
	@content
end