1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/lib/pry/output.rb
Ryan Fitzgerald cb2f8c08f6 Fix behavior of Pry::Output#puts
This implementation of puts didn't behave correctly in the presence of
multiple arguments or arguments that are Arrays. I changed it to match
the documented behavior of IO#puts, but we might still be missing some
subtleties.
2014-05-05 00:39:31 -07:00

44 lines
858 B
Ruby

class Pry
class Output
attr_reader :_pry_
def initialize(_pry_)
@_pry_ = _pry_
end
def puts(*objs)
return print "\n" if objs.empty?
objs.each do |obj|
if obj.is_a?(Array)
puts(*obj)
else
print "#{obj.to_s.chomp}\n"
end
end
end
def print(str)
_pry_.config.output.print decolorize_maybe(str)
end
alias << print
alias write print
# If _pry_.config.color is currently false, removes ansi escapes from the string.
def decolorize_maybe(str)
if _pry_.config.color
str
else
Helpers::Text.strip_color str
end
end
def method_missing(name, *args, &block)
_pry_.config.output.send(name, *args, &block)
end
def respond_to_missing?(*a)
_pry_.config.respond_to?(*a)
end
end
end