class Redditor
Rubbit
Object¶ ↑
Object Representing a Redditor
. If the requested Redditor
is logged in, this object also contains a modhash. If obtained from a subreddit list, this object will need to be rebuilt using the rebuild function
Public Class Methods
# File lib/Rubbit/Rubbit_Objects.rb, line 271 def initialize(json) if(json['kind']=='t2') data = json['data'] data.each_key do |k| self.class.module_eval {attr_accessor(k)} self.send("#{k}=",data[k]) end elsif(json['id'][0..2]=='t2_') data = json data.each_key do |k| self.class.module_eval {attr_accessor(k)} self.send("#{k}=",data[k]) end end end
Public Instance Methods
Description¶ ↑
Function for getting user comment from a profile
Attributes¶ ↑
-
limit
- Maximum entries that theContentGenerator
can contain -
sort
- Sort order by which the content is returned
# File lib/Rubbit/Rubbit_Objects.rb, line 309 def get_comments(limit=100,sort='new') return ContentGenerator.new('http://www.reddit.com/user/'+@name.to_s+'/comments.json?sort='+sort,limit) end
Description¶ ↑
Function for getting user overview content from a profile, including both comments and posts
Attributes¶ ↑
-
limit
- Maximum entries that theContentGenerator
can contain -
sort
- Sort order by which the content is returned
# File lib/Rubbit/Rubbit_Objects.rb, line 296 def get_overview(limit=100,sort='new') return ContentGenerator.new('http://www.reddit.com/user/'+@name.to_s+'/.json?sort='+sort,limit) end
Description¶ ↑
Function for getting user posts from a profile
Attributes¶ ↑
-
limit
- Maximum entries that theContentGenerator
can contain -
sort
- Sort order by which the content is returned
# File lib/Rubbit/Rubbit_Objects.rb, line 322 def get_submitted(limit=100,sort='new') return ContentGenerator.new('http://www.reddit.com/user/'+@name.to_s+'/submitted.json?sort='+sort,limit) end
Description¶ ↑
Function for rebuilding user object using data from their profile page
# File lib/Rubbit/Rubbit_Objects.rb, line 330 def rebuild rebuilt_user = Rubbit_Object_Builder.instance.build_user(@name) rebuilt_user.instance_variables.each do |attr_name| self.class.module_eval{attr_accessor(attr_name[1..-1])} self.send("#{attr_name[1..-1]}=",rebuilt_user.instance_variable_get(attr_name)) end end