Class: Beagle::BeagleResultsHelper
Instance Method Summary collapse
-
#initialize(io) ⇒ BeagleResultsHelper
constructor
A new instance of BeagleResultsHelper.
- #next ⇒ Object
Constructor Details
#initialize(io) ⇒ BeagleResultsHelper
Returns a new instance of BeagleResultsHelper.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/darkext/beagle.rb', line 11 def initialize(io) @io = io @fiber = Fiber.new do while !@io.eof? result = Hash.new loop do line = @io.gets break if line.nil? line.chomp! break if line.empty? && 0 < result.keys.size if !line.include?('=') || line.starts_with?(' Snip') parts = line.split(':') k = parts.shift.strip v = parts.join(':').strip result[k] = v unless k.empty? || v.empty? elsif line.include?('=') k,v = line.split('=') k = k.split(':').last.strip v = v.gsub("'",'').strip result[k] = v unless k.empty? || v.empty? end end Fiber.yield(result) end @io.close end end |
Instance Method Details
#next ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/darkext/beagle.rb', line 39 def next begin return @fiber.resume rescue FiberError return nil end end |