IronRuby.Builtins.RubyBufferedStream.ReadLine C# (CSharp) Method

ReadLine() public method

public ReadLine ( MutableString separator, IronRuby.Builtins.RubyEncoding encoding, bool preserveEndOfLines, int limit ) : MutableString
separator MutableString
encoding IronRuby.Builtins.RubyEncoding
preserveEndOfLines bool
limit int
return MutableString
        public MutableString ReadLine(MutableString/*!*/ separator, RubyEncoding/*!*/ encoding, bool preserveEndOfLines, int limit) {
            // TODO: limit

            int b = ReadByteNormalizeEoln(preserveEndOfLines);
            if (b == -1) {
                return null;
            }

            int separatorOffset = 0;
            int separatorLength = separator.GetByteCount();
            MutableString result = MutableString.CreateBinary(encoding);

            do {
                result.Append((byte)b);

                if (b == separator.GetByte(separatorOffset)) {
                    if (separatorOffset == separatorLength - 1) {
                        break;
                    }
                    separatorOffset++;
                } else if (separatorOffset > 0) {
                    separatorOffset = 0;
                }

                b = ReadByteNormalizeEoln(preserveEndOfLines);
            } while (b != -1);

            return result;
        }

Same methods

RubyBufferedStream::ReadLine ( IronRuby.Builtins.RubyEncoding encoding, bool preserveEndOfLines, int limit ) : MutableString

Usage Example

コード例 #1
0
ファイル: IoTests.cs プロジェクト: rudimk/dlr-dotnet
 private void TestReadLine(RubyBufferedStream/*!*/ io, bool preserveEolns, string expected) {
     var s = io.ReadLine(RubyEncoding.Binary, preserveEolns);
     Assert(s == null && expected == null || s.ToString() == expected);
 }