Skip to content

Commit

Permalink
EasterEgg no longer depend on RDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Sep 3, 2024
1 parent 87d0754 commit 95a190f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/irb/easter-egg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ def render_frame(i)
end

private def easter_egg(type = nil)
print "\e[?1049h"
type ||= [:logo, :dancing].sample
case type
when :logo
require "rdoc"
RDoc::RI::Driver.new.page do |io|
type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large
io.write easter_egg_logo(type)
Pager.page do |io|
logo_type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large
io.write easter_egg_logo(logo_type)
STDIN.raw { STDIN.getc } if io == STDOUT
end
when :dancing
STDOUT.cooked do
Expand All @@ -138,10 +139,11 @@ def render_frame(i)
end
rescue Interrupt
ensure
print "\e[0m\e[?1049l"
trap("SIGINT", prev_trap)
end
end
ensure
print "\e[0m\e[?1049l"
end
end
end
Expand Down

0 comments on commit 95a190f

Please sign in to comment.