Class: Snooby::Subreddit

Inherits:
Object
  • Object
show all
Includes:
About, Comments, Compose, Posts
Defined in:
lib/snooby/subreddit.rb

Instance Method Summary collapse

Methods included from About

#about

Methods included from Posts

#posts

Methods included from Comments

#comments

Methods included from Compose

#compose

Constructor Details

#initialize(name) ⇒ Subreddit

Returns a new instance of Subreddit.



5
6
7
8
# File 'lib/snooby/subreddit.rb', line 5

def initialize(name)
  @name = name
  @kind = 'subreddit'
end

Instance Method Details

#subscribeObject Also known as: sub

Alas, (un)subscribing by name alone doesn’t work, so a separate call must be made to obtain the subreddit’s id, thus the wait. Maybe cache this?



12
13
14
15
16
# File 'lib/snooby/subreddit.rb', line 12

def subscribe
  sr = about['name']
  Snooby.wait
  Snooby.request(Paths[:subscribe], :action => 'sub', :sr => sr)
end

#unsubscribeObject Also known as: unsub



19
20
21
22
23
# File 'lib/snooby/subreddit.rb', line 19

def unsubscribe
  sr = about['name']
  Snooby.wait
  Snooby.request(Paths[:subscribe], :action => 'unsub', :sr => sr)
end