Class: Post

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

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Post

Returns a new instance of Post.



209
210
211
212
213
214
215
216
217
218
# File 'lib/Rubbit/Rubbit_Objects.rb', line 209

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

#commentsObject



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

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

#reply(text) ⇒ Object



219
220
221
# File 'lib/Rubbit/Rubbit_Objects.rb', line 219

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