Class: Reddit::User
- Includes:
- JsonListing
- Defined in:
- lib/ruby_reddit_api/user.rb
Overview
Instance Attribute Summary collapse
-
#comment_karma ⇒ Object
readonly
Returns the value of attribute comment_karma.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#created_utc ⇒ Object
readonly
Returns the value of attribute created_utc.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#has_mod_mail ⇒ Object
readonly
Returns the value of attribute has_mod_mail.
-
#is_mod ⇒ Object
readonly
Returns the value of attribute is_mod.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#link_karma ⇒ Object
readonly
Returns the value of attribute link_karma.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Api
#last_action, #password, #user
Attributes inherited from Base
Instance Method Summary collapse
-
#friend ⇒ true, false
Add redditor as friend.
-
#id ⇒ String
The reddit ID of this submission.
-
#initialize(json) ⇒ User
constructor
A new instance of User.
- #inspect ⇒ Object
- #to_s ⇒ String
-
#unfriend ⇒ true, false
Remove redditor as friend.
Methods included from JsonListing
Methods inherited from Api
#browse, #comments, #post_replies, #received_messages, #search, #sent_messages, #unread_messages
Methods inherited from Base
base_headers, #base_headers, #cookie, #logged_in?, #login, #logout, #modhash, #read, #user, #user_agent, user_agent, #user_id
Constructor Details
#initialize(json) ⇒ User
Returns a new instance of User.
6 7 8 9 |
# File 'lib/ruby_reddit_api/user.rb', line 6 def initialize(json) @debug = StringIO.new parse(json) end |
Instance Attribute Details
#comment_karma ⇒ Object (readonly)
Returns the value of attribute comment_karma.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def comment_karma @comment_karma end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def created @created end |
#created_utc ⇒ Object (readonly)
Returns the value of attribute created_utc.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def created_utc @created_utc end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def debug @debug end |
#has_mod_mail ⇒ Object (readonly)
Returns the value of attribute has_mod_mail.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def has_mod_mail @has_mod_mail end |
#is_mod ⇒ Object (readonly)
Returns the value of attribute is_mod.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def is_mod @is_mod end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def kind @kind end |
#link_karma ⇒ Object (readonly)
Returns the value of attribute link_karma.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def link_karma @link_karma end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/ruby_reddit_api/user.rb', line 5 def name @name end |
Instance Method Details
#friend ⇒ true, false
Add redditor as friend. Requires a authenticated user.
28 29 30 31 32 |
# File 'lib/ruby_reddit_api/user.rb', line 28 def friend capture_user_id resp=self.class.post("/api/friend", {:body => {:name => name, :container => user_id, :type => "friend", :uh => modhash}, :headers => base_headers, :debug_output => @debug }) resp.code == 200 end |
#id ⇒ String
The reddit ID of this submission
17 18 19 |
# File 'lib/ruby_reddit_api/user.rb', line 17 def id "#{kind}_#{@id}" end |
#inspect ⇒ Object
11 12 13 |
# File 'lib/ruby_reddit_api/user.rb', line 11 def inspect "<Reddit::User name='#{name}'>" end |
#to_s ⇒ String
22 23 24 |
# File 'lib/ruby_reddit_api/user.rb', line 22 def to_s name end |
#unfriend ⇒ true, false
Remove redditor as friend. Requires a authenticated user.
36 37 38 39 40 |
# File 'lib/ruby_reddit_api/user.rb', line 36 def unfriend capture_user_id resp=self.class.post("/api/unfriend", {:body => {:name => name, :container => user_id, :type => "friend", :uh => modhash}, :headers => base_headers, :debug_output => @debug }) resp.code == 200 end |