Beispiel #1
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);
        }
Beispiel #2
0
        public MutableString /*!*/ Format()
        {
            _index   = 0;
            _buf     = new StringBuilder();
            _tainted = false;
            int modIndex;

            while ((modIndex = _format.IndexOf('%', _index)) != -1)
            {
                _buf.Append(_format, _index, modIndex - _index);
                _index = modIndex + 1;
                DoFormatCode();
            }
            _buf.Append(_format, _index, _format.Length - _index);

            MutableString result = MutableString.Create(_buf.ToString());

            if (_tainted)
            {
                KernelOps.Taint(_context, result);
            }

            return(result);
        }
Beispiel #3
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);
        }