Class: Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/Rubbit/Rubbit_Objects.rb

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Comment

Returns a new instance of Comment.



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/Rubbit/Rubbit_Objects.rb', line 180

def initialize(json)
	if(json['kind']=='t1')
		data = json['data']
		data.each_key do |k|
			self.class.module_eval {attr_accessor(k)}
			self.send("#{k}=",data[k])
		end
		children = []
		if(@replies!= nil and @replies['data']!=nil and @replies['data']['children']!=nil)
			@replies['data']['children'].each do |c|
				if(c!=nil)
					children += [Comment.new(c)]
				end
			end
			@replies = children
		end
		if(@replies=="")
			replies = nil
		end
	end
end

Instance Method Details

#deleteObject



206
207
208
# File 'lib/Rubbit/Rubbit_Objects.rb', line 206

def delete
	Rubbit_Poster.instance.delete(@name)
end

#edit(text) ⇒ Object



210
211
212
# File 'lib/Rubbit/Rubbit_Objects.rb', line 210

def edit(text)
	Rubbit_Poster.instance.edit(@name,text)
end

#hideObject



214
215
216
# File 'lib/Rubbit/Rubbit_Objects.rb', line 214

def hide
	Rubbit_Poster.instance.hide(@name)
end

#reply(text) ⇒ Object



202
203
204
# File 'lib/Rubbit/Rubbit_Objects.rb', line 202

def reply(text)
	Rubbit_Poster.instance.comment(@name,text)
end