ReadLineOrParagraph() public method

public ReadLineOrParagraph ( MutableString separator, int limit ) : MutableString
separator MutableString
limit int
return MutableString
Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static MutableString Gets(RubyScope /*!*/ scope, RubyIO /*!*/ self, [DefaultProtocol] MutableString separator)
        {
            MutableString result = self.ReadLineOrParagraph(separator);

            KernelOps.Taint(scope.RubyContext, result);

            scope.GetInnerMostClosureScope().LastInputLine = result;
            scope.RubyContext.InputProvider.IncrementLastInputLineNumber();

            return(result);
        }
Ejemplo n.º 3
0
        public static MutableString Gets(RubyScope /*!*/ scope, RubyIO /*!*/ self, [DefaultProtocol] MutableString separator)
        {
            MutableString result = self.ReadLineOrParagraph(separator);

            if (result != null)
            {
                result.IsTainted = true;
            }

            scope.GetInnerMostClosureScope().LastInputLine = result;
            scope.RubyContext.InputProvider.LastInputLineNumber = ++self.LineNumber;

            return(result);
        }
Ejemplo n.º 4
0
        public static RubyArray /*!*/ ReadLines(RubyContext /*!*/ context, RubyIO /*!*/ self, [DefaultProtocol] MutableString separator)
        {
            RubyArray result = new RubyArray();

            // no dynamic call, doesn't modify $_ scope variable:
            MutableString line;

            while ((line = self.ReadLineOrParagraph(separator)) != null)
            {
                result.Add(line);
            }

            context.InputProvider.LastInputLineNumber += result.Count;
            return(result);
        }
Ejemplo n.º 5
0
        public static object Each(BlockParam block, RubyIO /*!*/ self, [DefaultProtocol] MutableString separator)
        {
            self.AssertOpenedForReading();

            MutableString line;

            while ((line = self.ReadLineOrParagraph(separator)) != null)
            {
                if (block == null)
                {
                    throw RubyExceptions.NoBlockGiven();
                }

                KernelOps.Taint(block.RubyContext, line);

                object result;
                if (block.Yield(line, out result))
                {
                    return(result);
                }
            }

            return(self);
        }
Ejemplo n.º 6
0
        public static RubyArray/*!*/ ReadLines(RubyContext/*!*/ context, RubyIO/*!*/ self, [DefaultProtocol]MutableString separator, [DefaultProtocol]int limit) {
            RubyArray result = new RubyArray();

            // no dynamic call, doesn't modify $_ scope variable:
            MutableString line;
            while ((line = self.ReadLineOrParagraph(separator, limit)) != null) {
                result.Add(line);
            }

            self.LineNumber += result.Count;
            context.InputProvider.LastInputLineNumber = self.LineNumber;
            return result;
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        public static MutableString Gets(RubyScope/*!*/ scope, RubyIO/*!*/ self, [DefaultProtocol]MutableString separator, [DefaultProtocol]int limit) {

            MutableString result = self.ReadLineOrParagraph(separator, limit);
            if (result != null) {
                result.IsTainted = true;
            }

            scope.GetInnerMostClosureScope().LastInputLine = result;
            scope.RubyContext.InputProvider.LastInputLineNumber = ++self.LineNumber;

            return result;
        }
Ejemplo n.º 9
0
        public static object Each(BlockParam block, RubyIO/*!*/ self, [DefaultProtocol]MutableString separator) {
            self.AssertOpenedForReading();

            MutableString line;
            while ((line = self.ReadLineOrParagraph(separator)) != null) {
                if (block == null) {
                    throw RubyExceptions.NoBlockGiven();
                }

                KernelOps.Taint(block.RubyContext, line);

                object result;
                if (block.Yield(line, out result)) {
                    return result;
                }
            }

            return self;
        }
Ejemplo n.º 10
0
        public static MutableString Gets(RubyScope/*!*/ scope, RubyIO/*!*/ self, [DefaultProtocol]MutableString separator) {

            MutableString result = self.ReadLineOrParagraph(separator);
            KernelOps.Taint(scope.RubyContext, result);

            scope.GetInnerMostClosureScope().LastInputLine = result;
            scope.RubyContext.InputProvider.IncrementLastInputLineNumber();

            return result;
        }