-
Notifications
You must be signed in to change notification settings - Fork 1
/
smoods_board.rb
59 lines (46 loc) · 1.29 KB
/
smoods_board.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'rubygems'
require 'smoodit'
class SmoodsBoard
def smooder_board_of mooders
moods = {}
pages = 0
Smoodit.send(mooders.username.to_sym).smoods do |resp|
pages = resp.pages
end
(1..pages).each do |p|
puts "#{mooders.username}_#{p}/#{pages}"
Smoodit.send(mooders.username.to_sym).smoods(:page => p) do |resp|
resp.smoods.each do |m|
moods[m.mood] = 0 if moods[m.mood].nil?
moods[m.mood] += 1
end
end
end
moods
end
def people_smoodsboard(you, kind)
smoodboard = {}
pages = 0
Smoodit.send(you.to_sym).send(kind.to_sym) do |resp|
pages = resp.pages
end
(1..pages).each do |p|
puts "=== your #{kind} (page #{p} of #{pages}) ==="
Smoodit.send(you.to_sym).send(kind.to_sym, :page => p) do |resp|
resp.send(kind.to_sym).each do |f|
moods = smooder_board_of f
moods.each_pair do |m, q|
smoodboard[m] = {:smooder => f, :points => q} if smoodboard[m].nil? || smoodboard[m][:points] < q
end
end
end
end
smoodboard
end
def following_smoodsboard you
people_smoodsboard(you, "following")
end
def followers_smoodsboard you
people_smoodsboard(you, "followers")
end
end