Class: Snooby::Subreddit
- Inherits:
-
Object
- Object
- Snooby::Subreddit
- Defined in:
- lib/snooby/subreddit.rb
Instance Method Summary collapse
-
#initialize(name) ⇒ Subreddit
constructor
A new instance of Subreddit.
-
#subscribe ⇒ Object
(also: #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.
- #unsubscribe ⇒ Object (also: #unsub)
Methods included from About
Methods included from Posts
Methods included from Comments
Methods included from 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
#subscribe ⇒ Object 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 |
#unsubscribe ⇒ Object 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 |