public static object Each(RubyContext /*!*/ context, BlockParam block, RubyIO /*!*/ self, [DefaultProtocol] MutableString separator) { self.RequireReadable(); MutableString line; while ((line = self.ReadLineOrParagraph(separator)) != null) { if (block == null) { throw RubyExceptions.NoBlockGiven(); } line.IsTainted = true; context.InputProvider.LastInputLineNumber = ++self.LineNumber; object result; if (block.Yield(line, out result)) { return(result); } } return(self); }
public static int ReadChar(RubyIO /*!*/ self) { self.RequireReadable(); int c = self.ReadByteNormalizeEoln(); if (c == -1) { throw new EOFError("end of file reached"); } return(c); }
public static object EachByte(BlockParam block, RubyIO /*!*/ self) { self.RequireReadable(); object aByte; while ((aByte = Getc(self)) != null) { if (block == null) { throw RubyExceptions.NoBlockGiven(); } object result; if (block.Yield((int)aByte, out result)) { return(result); } } return(self); }
public static MutableString Read(RubyIO /*!*/ self, [DefaultProtocol] int bytes, [DefaultProtocol, Optional] MutableString buffer) { self.RequireReadable(); if (bytes < 0) { throw RubyExceptions.CreateArgumentError("negative length -1 given"); } if (buffer == null) { buffer = MutableString.CreateBinary(); } else { buffer.Clear(); } int bytesRead = self.AppendBytes(buffer, bytes); return((bytesRead == 0 && bytes != 0) ? null : buffer); }
public static int ReadChar(RubyIO/*!*/ self) { self.RequireReadable(); int c = self.ReadByteNormalizeEoln(); if (c == -1) { throw new EOFError("end of file reached"); } return c; }
public static MutableString Read(RubyIO/*!*/ self, [DefaultProtocol]int bytes, [DefaultProtocol, Optional]MutableString buffer) { self.RequireReadable(); if (bytes < 0) { throw RubyExceptions.CreateArgumentError("negative length -1 given"); } buffer = PrepareReadBuffer(self, buffer); int bytesRead = self.AppendBytes(buffer, bytes); return (bytesRead == 0 && bytes != 0) ? null : buffer; }
public static bool Eof(RubyIO/*!*/ self) { self.RequireReadable(); return self.IsEndOfStream(); }
public static object EachByte(BlockParam block, RubyIO/*!*/ self) { self.RequireReadable(); object aByte; while ((aByte = Getc(self)) != null) { if (block == null) { throw RubyExceptions.NoBlockGiven(); } object result; if (block.Yield((int)aByte, out result)) { return result; } } return self; }
public static object Each(RubyContext/*!*/ context, BlockParam block, RubyIO/*!*/ self, [DefaultProtocol]MutableString separator, [DefaultProtocol]int limit) { self.RequireReadable(); MutableString line; while ((line = self.ReadLineOrParagraph(separator, limit)) != null) { if (block == null) { throw RubyExceptions.NoBlockGiven(); } line.IsTainted = true; context.InputProvider.LastInputLineNumber = ++self.LineNumber; object result; if (block.Yield(line, out result)) { return result; } } return self; }
public static MutableString ReadNoBlock(RubyIO/*!*/ self, [DefaultProtocol]int bytes, [DefaultProtocol, Optional]MutableString buffer) { self.RequireReadable(); MutableString result = null; self.NonBlockingOperation(() => result = Read(self, bytes, buffer), true); if (result == null) { throw new EOFError("end of file reached"); } return result; }
public static bool Eof(RubyIO /*!*/ self) { self.RequireReadable(); return(self.IsEndOfStream()); }