Skip to content

Instantly share code, notes, and snippets.

@bitops
Created January 28, 2012 05:01
Show Gist options
  • Select an option

  • Save bitops/1692720 to your computer and use it in GitHub Desktop.

Select an option

Save bitops/1692720 to your computer and use it in GitHub Desktop.
Bad file descriptors
class LogReader
def initialize(f)
@f = f
end
def process
yield(@f.read)
end
end
count = 0
io = IO.new File.open('example.log', 'r').to_i
lr = LogReader.new io
while true do
count += 1
puts "Count: #{count}"
lr.process {|d| puts "Data: #{d}"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment