Class: Reddit::Submission
- Includes:
- JsonListing, Voteable
- Defined in:
- lib/ruby_reddit_api/submission.rb
Instance Attribute Summary collapse
-
#clicked ⇒ Object
readonly
Returns the value of attribute clicked.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#created_utc ⇒ Object
readonly
Returns the value of attribute created_utc.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#downs ⇒ Object
readonly
Returns the value of attribute downs.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#is_self ⇒ Object
readonly
Returns the value of attribute is_self.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#last_comment_id ⇒ Object
readonly
Returns the value of attribute last_comment_id.
-
#likes ⇒ Object
readonly
Returns the value of attribute likes.
-
#media ⇒ Object
readonly
Returns the value of attribute media.
-
#media_embed ⇒ Object
readonly
Returns the value of attribute media_embed.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#num_comments ⇒ Object
readonly
Returns the value of attribute num_comments.
-
#over_18 ⇒ Object
readonly
Returns the value of attribute over_18.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#saved ⇒ Object
readonly
Returns the value of attribute saved.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#selftext ⇒ Object
readonly
Returns the value of attribute selftext.
-
#selftext_html ⇒ Object
readonly
Returns the value of attribute selftext_html.
-
#subreddit ⇒ Object
readonly
Returns the value of attribute subreddit.
-
#subreddit_id ⇒ Object
readonly
Returns the value of attribute subreddit_id.
-
#thumbnail ⇒ Object
readonly
Returns the value of attribute thumbnail.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#ups ⇒ Object
readonly
Returns the value of attribute ups.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Base
Instance Method Summary collapse
-
#add_comment(text) ⇒ true, false
Add a comment to a submission.
- #admin_distinguish ⇒ Object
-
#comments ⇒ Array<Reddit::Comment>
Fetch submission comments.
-
#hide ⇒ true, false
Hide submission.
- #indistinguish ⇒ Object
- #inspect ⇒ Object
- #moderator_distinguish ⇒ Object
-
#save ⇒ true, false
Save submission.
-
#unhide ⇒ true, false
Unhide submission.
-
#unsave ⇒ true, false
Unsave submission.
Methods included from Voteable
Methods included from JsonListing
Methods inherited from Thing
#author, #id, #initialize, #report, #toggle
Methods inherited from Base
base_headers, #base_headers, #cookie, #initialize, #logged_in?, #login, #logout, #modhash, #read, #user, #user_agent, user_agent, #user_id
Constructor Details
This class inherits a constructor from Reddit::Thing
Instance Attribute Details
#clicked ⇒ Object (readonly)
Returns the value of attribute clicked.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def clicked @clicked end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def created @created end |
#created_utc ⇒ Object (readonly)
Returns the value of attribute created_utc.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def created_utc @created_utc end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def domain @domain end |
#downs ⇒ Object (readonly)
Returns the value of attribute downs.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def downs @downs end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def hidden @hidden end |
#is_self ⇒ Object (readonly)
Returns the value of attribute is_self.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def is_self @is_self end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def kind @kind end |
#last_comment_id ⇒ Object (readonly)
Returns the value of attribute last_comment_id.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def last_comment_id @last_comment_id end |
#likes ⇒ Object (readonly)
Returns the value of attribute likes.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def likes @likes end |
#media ⇒ Object (readonly)
Returns the value of attribute media.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def media @media end |
#media_embed ⇒ Object (readonly)
Returns the value of attribute media_embed.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def @media_embed end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def name @name end |
#num_comments ⇒ Object (readonly)
Returns the value of attribute num_comments.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def num_comments @num_comments end |
#over_18 ⇒ Object (readonly)
Returns the value of attribute over_18.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def over_18 @over_18 end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def permalink @permalink end |
#saved ⇒ Object (readonly)
Returns the value of attribute saved.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def saved @saved end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def score @score end |
#selftext ⇒ Object (readonly)
Returns the value of attribute selftext.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def selftext @selftext end |
#selftext_html ⇒ Object (readonly)
Returns the value of attribute selftext_html.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def selftext_html @selftext_html end |
#subreddit ⇒ Object (readonly)
Returns the value of attribute subreddit.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def subreddit @subreddit end |
#subreddit_id ⇒ Object (readonly)
Returns the value of attribute subreddit_id.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def subreddit_id @subreddit_id end |
#thumbnail ⇒ Object (readonly)
Returns the value of attribute thumbnail.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def thumbnail @thumbnail end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def title @title end |
#ups ⇒ Object (readonly)
Returns the value of attribute ups.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def ups @ups end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/ruby_reddit_api/submission.rb', line 7 def url @url end |
Instance Method Details
#add_comment(text) ⇒ true, false
Add a comment to a submission
16 17 18 19 |
# File 'lib/ruby_reddit_api/submission.rb', line 16 def add_comment(text) resp = self.class.post("/api/comment", {:body => {:thing_id => id, :text => text, :uh => modhash, :r => subreddit }, :headers => base_headers, :debug_output => @debug }) resp.code == 200 end |
#admin_distinguish ⇒ Object
49 50 51 |
# File 'lib/ruby_reddit_api/submission.rb', line 49 def admin_distinguish add_distinction "admin" end |
#comments ⇒ Array<Reddit::Comment>
Move to ‘Thing’ class
Fetch submission comments
60 61 62 63 64 65 |
# File 'lib/ruby_reddit_api/submission.rb', line 60 def comments _comments = read( permalink + ".json", {:handler => "Comment", :query => {:limit => 250}} ) @last_comment_id = _comments.last.id if _comments && _comments.any? _comments.shift # First 'comment' is actually the submission return _comments end |
#hide ⇒ true, false
Hide submission
35 36 37 |
# File 'lib/ruby_reddit_api/submission.rb', line 35 def hide toggle :hide end |
#indistinguish ⇒ Object
53 54 55 |
# File 'lib/ruby_reddit_api/submission.rb', line 53 def indistinguish add_distinction "no" end |
#inspect ⇒ Object
9 10 11 |
# File 'lib/ruby_reddit_api/submission.rb', line 9 def inspect "<Reddit::Submission id='#{id}' author='#{@author}' title='#{title}'>" end |
#moderator_distinguish ⇒ Object
45 46 47 |
# File 'lib/ruby_reddit_api/submission.rb', line 45 def moderator_distinguish add_distinction "yes" end |
#save ⇒ true, false
Save submission
23 24 25 |
# File 'lib/ruby_reddit_api/submission.rb', line 23 def save toggle :save end |
#unhide ⇒ true, false
Unhide submission
41 42 43 |
# File 'lib/ruby_reddit_api/submission.rb', line 41 def unhide toggle :unhide end |
#unsave ⇒ true, false
Unsave submission
29 30 31 |
# File 'lib/ruby_reddit_api/submission.rb', line 29 def unsave toggle :unsave end |