23 lines
339 B
Ruby
23 lines
339 B
Ruby
|
require 'mongo'
|
||
|
|
||
|
module PrototypeR4
|
||
|
module GridIO
|
||
|
|
||
|
def self.included(base)
|
||
|
base.class_eval do
|
||
|
|
||
|
def size
|
||
|
(file_length / chunk_size) + (file_length % chunk_size > 0 ? 1 : 0)
|
||
|
end
|
||
|
|
||
|
def each(&block)
|
||
|
size.times { block.call(read(chunk_size)) }
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|
||
|
|