Class: JSONQueue
- Inherits:
-
Queue
- Object
- Queue
- JSONQueue
- Defined in:
- lib/reimporter.rb
Instance Method Summary collapse
- #add_to_queue ⇒ Object
-
#initialize(opts) ⇒ JSONQueue
constructor
A new instance of JSONQueue.
- #offset(amount) ⇒ Object
Constructor Details
#initialize(opts) ⇒ JSONQueue
Returns a new instance of JSONQueue.
2 3 4 5 6 |
# File 'lib/reimporter.rb', line 2 def initialize(opts) super() @io = IO.open(IO.sysopen(opts[:file])) @counter = opts[:counter] end |
Instance Method Details
#add_to_queue ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/reimporter.rb', line 15 def add_to_queue 100.times do self << JSON.parse(@io.readline) end @counter += 100 puts "Adding 100 lines to queue, #{@counter} so far" end |
#offset(amount) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/reimporter.rb', line 8 def offset(amount) puts "Offsetting by #{amount}" amount.times do @io.readline end end |