Class: Post

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

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Post



221
222
223
224
225
226
227
228
229
230
# File 'lib/Rubbit/Rubbit_Objects.rb', line 221

def initialize(json)
  @comments = nil
  if(json['kind']=='t3')
    data = json['data']
    data.each_key do |k|
      self.class.module_eval {attr_accessor(k)}
      self.send("#{k}=",data[k])
    end
  end
end

Instance Method Details

#deleteObject



242
243
244
# File 'lib/Rubbit/Rubbit_Objects.rb', line 242

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

#edit(text) ⇒ Object



246
247
248
# File 'lib/Rubbit/Rubbit_Objects.rb', line 246

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

#hideObject



250
251
252
# File 'lib/Rubbit/Rubbit_Objects.rb', line 250

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

#mark_nsfwObject



254
255
256
# File 'lib/Rubbit/Rubbit_Objects.rb', line 254

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

#repliesObject



235
236
237
238
239
240
# File 'lib/Rubbit/Rubbit_Objects.rb', line 235

def replies
  if(@comments==nil)
    @comments = Rubbit_Object_Builder.instance.get_comments('http://www.reddit.com'+@permalink).children
  end
  return @comments
end

#reply(text) ⇒ Object



231
232
233
# File 'lib/Rubbit/Rubbit_Objects.rb', line 231

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