Rubbit 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/Rubbit/Rubbit_Objects.rb +38 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjZhZDFkZTc4NTQ0NDJlNTY4NmYxNTcxMTJlMTBjNzNiOWFjODQ5MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODc5YmQzYzFhMjExNzVjODlmZWNjMTg4MjhmYzdjMTk5MTJmZjRkYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGY0ODVjZTkxNTkzOGI3YjQ4ZGQzNTY2ZGI5YzA5MjkzYmY2ZDk0NjJiYzZh
|
10
|
+
NDQwMWNjOWNkMGZkY2U4Yjk3Y2NjZDY4OGYwM2E2YTA1N2Y3ZmFmMTg5YzIw
|
11
|
+
ODAxZDJhYWVmMDQ4MWI1MDkyYTg4MmFkNDFiN2E2YzI1MmMwOTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDZhODM0YTJiYjQ4ZTQ2NmE4NDIzMWVhYmQ4YjMxMWUyZWI4NDM3MTZkZDE0
|
14
|
+
YTQ2ZDY2MmQ1ZWQ2NzM5NzVkMDNlMzVlOGYzNDM3MzM2ODY0ODRiNTBjMDQw
|
15
|
+
NzkzMGQ3NjVjNWY3MDdhZDE0OWJjOWQxZWVjNzhiNGMxNTA4YjY=
|
@@ -131,16 +131,17 @@ class ContentGenerator
|
|
131
131
|
@data = nil
|
132
132
|
@after = nil
|
133
133
|
@modhash = nil
|
134
|
+
@index
|
134
135
|
def initialize(source,limit=100,after='')
|
135
136
|
@source = source
|
136
137
|
@limit = limit
|
137
138
|
@count = 0
|
138
139
|
@data = []
|
139
140
|
@after = after
|
141
|
+
@index = 0
|
140
142
|
end
|
141
143
|
|
142
144
|
def each
|
143
|
-
index = 0
|
144
145
|
if(@data.length==0)
|
145
146
|
if(@limit!=nil)
|
146
147
|
if(@limit-@count>0)
|
@@ -157,10 +158,10 @@ class ContentGenerator
|
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
160
|
-
while(index<@data.length)
|
161
|
-
yield @data[index]
|
162
|
-
index+=1
|
163
|
-
if(index==@data.length)
|
161
|
+
while(@index<@data.length)
|
162
|
+
yield @data[@index]
|
163
|
+
@index+=1
|
164
|
+
if(@index==@data.length)
|
164
165
|
if(@after==nil)
|
165
166
|
break
|
166
167
|
end
|
@@ -187,22 +188,42 @@ class ContentGenerator
|
|
187
188
|
end
|
188
189
|
|
189
190
|
def next
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
191
|
+
if(@index>=@data.length)
|
192
|
+
if(@limit!=nil)
|
193
|
+
if(@limit-@count>0)
|
194
|
+
listing = Rubbit_Object_Builder.instance.build_listing(@source+'?limit='+[@limit-@count,100].min.to_s+"&after="+@after+"&count="+@count.to_s)
|
195
|
+
@after = listing.after
|
196
|
+
@data += listing.children
|
197
|
+
@count += listing.children.length
|
198
|
+
end
|
199
|
+
else
|
200
|
+
listing = Rubbit_Object_Builder.instance.build_listing(@source+"?limit="+100.to_s+"&after="+@after+"&count="+@count.to_s)
|
201
|
+
puts(@source+"?limit="+100.to_s+"&after="+@after+"&count="+@count.to_s)
|
202
|
+
@after = listing.after
|
203
|
+
@data += listing.children
|
204
|
+
@count += listing.children.length
|
205
|
+
end
|
195
206
|
end
|
196
|
-
|
197
|
-
|
198
|
-
|
207
|
+
to_return = @data[@index]
|
208
|
+
if(to_return!=nil)
|
209
|
+
@index+=1
|
210
|
+
end
|
211
|
+
return to_return
|
212
|
+
end
|
213
|
+
|
214
|
+
def prev
|
215
|
+
if(@index>1)
|
216
|
+
@index-=1
|
217
|
+
return @data[@index-1]
|
199
218
|
else
|
200
|
-
|
201
|
-
@count+= listing.children.length
|
202
|
-
return listing.children[0]
|
219
|
+
return nil
|
203
220
|
end
|
204
221
|
end
|
205
222
|
|
223
|
+
def reset_generator(i=0)
|
224
|
+
@index=i
|
225
|
+
end
|
226
|
+
|
206
227
|
def length
|
207
228
|
return @data.length
|
208
229
|
end
|
@@ -298,6 +319,7 @@ class Message
|
|
298
319
|
end
|
299
320
|
end
|
300
321
|
end
|
322
|
+
|
301
323
|
def reply(text)
|
302
324
|
Rubbit_Poster.instance.comment(text,@name)
|
303
325
|
end
|