Module: Snooby::Reply

Included in:
Comment, Post
Defined in:
lib/snooby/actions.rb

Instance Method Summary collapse

Instance Method Details

#reply(text) ⇒ Object

Posts a reply to the calling object, which is either a post or a comment.

Raises:



31
32
33
34
35
36
37
38
39
# File 'lib/snooby/actions.rb', line 31

def reply(text)
  raise RedditError, 'You are not logged in.' unless Snooby.active

  data = {:parent => self.name, :text => text, :api_type => 'json'}
  resp = Snooby.request(Paths[:comment], data)
  json = JSON.parse(resp)['json']

  raise RedditError, jj(json) unless json['errors'].empty?
end