summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/deps/mruby-input-stream/mrblib/input_stream.rb
blob: d452f7ff13263058d48fa9489ae2fdffbcc23f7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class InputStream
  include Enumerable

  #
  # from String#each
  def each(&block)
    self.rewind
    while pos = self.byteindex(0x0a)
      block.call(self.read(pos+1))
    end
    rest = self.read()
    if rest
      block.call(rest)
    end
  end
end