twitter-lists 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/twitter-lists/list.rb +14 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/twitter-lists/list.rb
CHANGED
@@ -18,20 +18,29 @@ module Twitter
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def parse(str)
|
21
|
-
n= new
|
21
|
+
n = new
|
22
22
|
n.user, n.name = str.sub(/^@/,'').split('/')
|
23
23
|
n
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def parse_and_load(str)
|
27
|
+
n = parse(str)
|
28
|
+
n.load_members
|
29
|
+
n
|
30
|
+
end
|
31
|
+
|
32
|
+
def lists_to_sets(lists)
|
27
33
|
lists = lists.collect { |l| l.is_a?(List) ? l : parse(l) }
|
28
|
-
|
34
|
+
lists.collect { |l| l.load_members ; Set.new(l.members) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def union(*lists)
|
38
|
+
sets = lists_to_sets(lists)
|
29
39
|
sets.inject { |u,s| s.union u }.to_a
|
30
40
|
end
|
31
41
|
|
32
42
|
def intersection(*lists)
|
33
|
-
|
34
|
-
sets = lists.collect { |l| Set.new l.members }
|
43
|
+
sets = lists_to_sets(lists)
|
35
44
|
sets.inject { |i,s| s.intersection i }.to_a
|
36
45
|
end
|
37
46
|
end
|