# frozen_string_literal: false
#
# output-method.rb - output methods used by irb
# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
module IRB
# An abstract output class for IO in irb. This is mainly used internally by
# IRB::Notifier. You can define your own output method to use with Irb.new,
# or Context.new
class OutputMethod
class NotImplementedError < StandardError
def initialize(val)
super("Need to define `#{val}'")
end
end
# Open this method to implement your own output method, raises a
# NotImplementedError if you don't define #print in your own class.
def print(*opts)
raise NotImplementedError, "print"
end
# Prints the given +opts+, with a newline delimiter.
def printn(*opts)
print opts.join(" "), "\n"
end
# Extends IO#printf to format the given +opts+ for Kernel#sprintf using
# #parse_printf_format
def printf(format, *opts)
if /(%*)%I/ =~ format
format, opts = parse_printf_format(format, opts)
end
print sprintf(format, *opts)
end
# Returns an array of the given +format+ and +opts+ to be used by
# Kernel#sprintf, if there was a successful Regexp match in the given
# +format+ from #printf
#
# %
#