module IRB

def easter_egg(type = nil)

def easter_egg(type = nil)
|= [:logo, :dancing].sample
ype
logo
.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
quire "rdoc"
oc::RI::Driver.new.page do |io|
IO.copy_stream(f, io)
d
dancing
n
nvas = Canvas.new(Reline.get_screen_size)
line::IOGate.set_winch_handler do
canvas = Canvas.new(Reline.get_screen_size)
d
by_model = RubyModel.new
int "\e[?1049h"
step do |i| # TODO (0..).each needs Ruby 2.6 or later
buff = canvas.draw do
  ruby_model.render_frame(i) do |p1, p2|
    canvas.line(p1, p2)
  end
end
buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
print "\e[H" + buff
sleep 0.05
d
ue Interrupt
re
int "\e[0m\e[?1049l"

def set_encoding(extern, intern = nil, override: true)

def set_encoding(extern, intern = nil, override: true)
  verbose, $VERBOSE = $VERBOSE, nil
  Encoding.default_external = extern unless extern.nil? || extern.empty?
  Encoding.default_internal = intern unless intern.nil? || intern.empty?
  [$stdin, $stdout, $stderr].each do |io|
    io.set_encoding(extern, intern)
  end
  if override
    @CONF[:LC_MESSAGES].instance_variable_set(:@override_encoding, extern)
  else
    @CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
  end
ensure
  $VERBOSE = verbose
end