Class: IOSegmenter::Reader
- Inherits:
-
Object
- Object
- IOSegmenter::Reader
- Includes:
- Enumerable
- Defined in:
- lib/io-segmenter/reader.rb
Constant Summary collapse
- DEFAULT_READ_SIZE =
8192
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(io, parser, max_read_size = DEFAULT_READ_SIZE) ⇒ Reader
constructor
A new instance of Reader.
Constructor Details
#initialize(io, parser, max_read_size = DEFAULT_READ_SIZE) ⇒ Reader
Returns a new instance of Reader.
9 10 11 12 13 |
# File 'lib/io-segmenter/reader.rb', line 9 def initialize(io, parser, max_read_size=DEFAULT_READ_SIZE) @io = io @parser = parser @max_read_size = max_read_size end |
Class Method Details
.foreach(*args, &block) ⇒ Object
23 24 25 |
# File 'lib/io-segmenter/reader.rb', line 23 def self.foreach(*args, &block) new(*args).each(&block) end |
Instance Method Details
#each ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/io-segmenter/reader.rb', line 15 def each until @io.eof? @parser.unpack(@io.read(@max_read_size)) do |segment| yield segment end end end |