Sha256: 21f8b083eab3b9821204e8035cb73b573d5c5cbfe61474c846da99b614a6f94c

Contents?: true

Size: 854 Bytes

Versions: 4

Compression:

Stored size: 854 Bytes

Contents

class Pry::Output
  attr_reader :_pry_

  def initialize(_pry_)
    @_pry_ = _pry_
    @boxed_io = _pry_.config.output
  end

  def puts(*objs)
    return print "\n" if objs.empty?
    objs.each do |obj|
      if ary = Array.try_convert(obj)
        puts(*ary)
      else
        print "#{obj.to_s.chomp}\n"
      end
    end
    nil
  end

  def print(*objs)
    objs.each do |obj|
      @boxed_io.print decolorize_maybe(obj.to_s)
    end
    nil
  end
  alias << print
  alias write print

  def tty?
    @boxed_io.respond_to?(:tty?) and @boxed_io.tty?
  end

  def method_missing(name, *args, &block)
    @boxed_io.__send__(name, *args, &block)
  end

  def respond_to_missing?(*a)
    @boxed_io.respond_to?(*a)
  end

  def decolorize_maybe(str)
    if _pry_.config.color
      str
    else
      Pry::Helpers::Text.strip_color str
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pry-0.11.0.pre2 lib/pry/output.rb
pry-0.11.0.pre2-java lib/pry/output.rb
pry-0.11.0.pre lib/pry/output.rb
pry-0.11.0.pre-java lib/pry/output.rb