Class: Lugg::Streamer
- Inherits:
-
Object
- Object
- Lugg::Streamer
- Defined in:
- lib/lugg/streamer.rb
Overview
The Streamer reads in content from an IO object and returns an Enumerator yielding Request objects.
Instance Method Summary collapse
-
#initialize(io) ⇒ Streamer
constructor
A new instance of Streamer.
- #records ⇒ Enumerator
Constructor Details
#initialize(io) ⇒ Streamer
Returns a new instance of Streamer.
11 12 13 |
# File 'lib/lugg/streamer.rb', line 11 def initialize(io) @io = io end |
Instance Method Details
#records ⇒ Enumerator
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lugg/streamer.rb', line 16 def records # rubocop:disable MethodLength Enumerator.new do |yielder| buffer = '' matcher = RequestMatcher.new io.each do |line| buffer << line if matcher =~ line if matcher.finished? yielder << Request.new(buffer) matcher = RequestMatcher.new buffer = '' end end end end |