Class: Reddit::User

Inherits:
Api
  • Object
show all
Defined in:
lib/ruby_reddit_api/user.rb

Instance Attribute Summary collapse

Attributes inherited from Api

#last_action

Instance Method Summary collapse

Methods inherited from Api

#browse, #comments, #post_replies, #received_messages, #sent_messages

Constructor Details

#initialize(json) ⇒ User

Returns a new instance of User.



5
6
7
8
# File 'lib/ruby_reddit_api/user.rb', line 5

def initialize(json)
  @debug = StringIO.new
  parse(json)
end

Instance Attribute Details

#comment_karmaObject (readonly)

Returns the value of attribute comment_karma.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def comment_karma
  @comment_karma
end

#createdObject (readonly)

Returns the value of attribute created.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def created
  @created
end

#created_utcObject (readonly)

Returns the value of attribute created_utc.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def created_utc
  @created_utc
end

#debugObject (readonly)

Returns the value of attribute debug.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def debug
  @debug
end

#has_mod_mailObject (readonly)

Returns the value of attribute has_mod_mail.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def has_mod_mail
  @has_mod_mail
end

#is_modObject (readonly)

Returns the value of attribute is_mod.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def is_mod
  @is_mod
end

#kindObject (readonly)

Returns the value of attribute kind.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def kind
  @kind
end

Returns the value of attribute link_karma.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def link_karma
  @link_karma
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/ruby_reddit_api/user.rb', line 4

def name
  @name
end

Instance Method Details

#friendObject



22
23
24
25
26
# File 'lib/ruby_reddit_api/user.rb', line 22

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

#idObject



14
15
16
# File 'lib/ruby_reddit_api/user.rb', line 14

def id
  "#{kind}_#{@id}"
end

#inspectObject



10
11
12
# File 'lib/ruby_reddit_api/user.rb', line 10

def inspect
  "<Reddit::User name='#{name}'>"
end

#to_sObject



18
19
20
# File 'lib/ruby_reddit_api/user.rb', line 18

def to_s
  name
end

#unfriendObject



28
29
30
31
32
# File 'lib/ruby_reddit_api/user.rb', line 28

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