class SyntaxSuggest::MiniStringIO
行为类似于 StringIO,但 API 减少,且无需引入该类。
原始代码直接输出到 $stderr,但现在 SyntaxError#detailed_message 需要字符串输出。为了实现这一点,我们保留了原有的打印基础设施,并添加了这个类来将打印输出累积到字符串中。
Constants
- EMPTY_ARG
属性
Public Class Methods
Source
# File lib/syntax_suggest/mini_stringio.rb, line 15 def initialize(isatty: $stderr.isatty) @string = +"" @isatty = isatty end
Public Instance Methods
Source
# File lib/syntax_suggest/mini_stringio.rb, line 21 def puts(value = EMPTY_ARG, **) if !value.equal?(EMPTY_ARG) @string << value end @string << $/ end