Class: Redditor

Inherits:
Object
  • Object
show all
Defined in:
lib/Rubbit/Rubbit_Objects.rb

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Redditor

Returns a new instance of Redditor.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/Rubbit/Rubbit_Objects.rb', line 60

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

Instance Method Details

#get_comments(limit = 100) ⇒ Object



80
81
82
# File 'lib/Rubbit/Rubbit_Objects.rb', line 80

def get_comments(limit=100)
	return ContentGenerator.new('http://www.reddit.com/user/'+@name.to_s+'/comments.json',limit)
end

#get_overview(limit = 100) ⇒ Object



76
77
78
# File 'lib/Rubbit/Rubbit_Objects.rb', line 76

def get_overview(limit=100)
	return ContentGenerator.new('http://www.reddit.com/user/'+@name.to_s+'/.json',limit)
end

#get_submitted(limit = 100) ⇒ Object



84
85
86
# File 'lib/Rubbit/Rubbit_Objects.rb', line 84

def (limit=100)
	return ContentGenerator.new('http://www.reddit.com/user/'+@name.to_s+'/submitted.json',limit)
end

#rebuildObject



88
89
90
91
92
93
94
# File 'lib/Rubbit/Rubbit_Objects.rb', line 88

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