ReadLineOrParagraph() public méthode

public ReadLineOrParagraph ( MutableString separator, int limit ) : MutableString
separator MutableString
limit int
Résultat MutableString
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #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;
        }