diff options
Diffstat (limited to 'lib/syntax_suggest/mini_stringio.rb')
-rw-r--r-- | lib/syntax_suggest/mini_stringio.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/syntax_suggest/mini_stringio.rb b/lib/syntax_suggest/mini_stringio.rb new file mode 100644 index 0000000000..ee5192ba90 --- /dev/null +++ b/lib/syntax_suggest/mini_stringio.rb @@ -0,0 +1,24 @@ +module SyntaxSuggest + # Mini String IO [Private] + # + # Acts like a StringIO with reduced API, but without having to require that + # class. + class MiniStringIO + EMPTY_ARG = Object.new + + def initialize(isatty: $stderr.isatty) + @string = +"" + @isatty = isatty + end + + attr_reader :isatty + def puts(value = EMPTY_ARG, **) + if !value.equal?(EMPTY_ARG) + @string << value + end + @string << $/ + end + + attr_reader :string + end +end |