Rubbit 0.0.10 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/Rubbit/Rubbit_Objects.rb +38 -16
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjUyYjZhMTBkMjVkNzU3ZWZkYzk1N2Y5MDFjYzNlNmQxMjRmNTVjYw==
4
+ YjZhZDFkZTc4NTQ0NDJlNTY4NmYxNTcxMTJlMTBjNzNiOWFjODQ5MQ==
5
5
  data.tar.gz: !binary |-
6
- YmQyYmZlMzM0ZTA2NmE5NDFmNzJmODNhYzUwMDIxMTRjZjFhYmUxZA==
6
+ ODc5YmQzYzFhMjExNzVjODlmZWNjMTg4MjhmYzdjMTk5MTJmZjRkYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjEwNjFjYzRhYzE5ODRiNzY5ZWMzZTQwZTdlZmVjOWUwZjJmNTAyNDkyMWYz
10
- MWIyYTJkYjQ3NzhmODUyMTVmNTg1ZWQxY2RkYWI1ZDM3ZjdjYTkwMDk4MGJi
11
- YmI5YTYyYjkzNGQzYzA5YjU1MzM3YjU0ZDk3Yzc4N2NkNWVjNjU=
9
+ MGY0ODVjZTkxNTkzOGI3YjQ4ZGQzNTY2ZGI5YzA5MjkzYmY2ZDk0NjJiYzZh
10
+ NDQwMWNjOWNkMGZkY2U4Yjk3Y2NjZDY4OGYwM2E2YTA1N2Y3ZmFmMTg5YzIw
11
+ ODAxZDJhYWVmMDQ4MWI1MDkyYTg4MmFkNDFiN2E2YzI1MmMwOTE=
12
12
  data.tar.gz: !binary |-
13
- NzMwMjFkOTI0MzE1NDZkN2I2MThjNDBlOTI0YTMyNDkyYjkzZTAwOTlhYmVl
14
- YTcyODk0MWRiNDY4MGQyMWViOTBhZjI1Yzg0YTVjNGU1MWFhNzcyYWQ2MzU1
15
- MTg4YjAwYTViNTQ3MTM5NjRlMjQwOGUyNjYzN2I5MmQ0MTZkNjk=
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
- listing = Rubbit_Object_Builder.instance.build_listing(@source+'?limit='+1.to_s+"&after="+@after+"&count="+@count.to_s)
191
- if(listing.children[listing.children.length-1]!=nil)
192
- @after = listing.children[listing.children.length-1].name
193
- else
194
- @after = nil
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
- if(@after == nil)
197
- @data+=[]
198
- return nil
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
- @data += listing.children
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Rubbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - /u/The1RGood