aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/easter-egg.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/easter-egg.rb')
-rw-r--r--lib/irb/easter-egg.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb
index 3e79692de9..1d7460abcd 100644
--- a/lib/irb/easter-egg.rb
+++ b/lib/irb/easter-egg.rb
@@ -98,15 +98,21 @@ module IRB
end
end
+ private def easter_egg_logo(type)
+ @easter_egg_logos ||= File.read(File.join(__dir__, 'ruby_logo.aa'), encoding: 'UTF-8:UTF-8')
+ .split(/TYPE: ([A-Z]+)\n/)[1..]
+ .each_slice(2)
+ .to_h
+ @easter_egg_logos[type.to_s.upcase]
+ end
+
private def easter_egg(type = nil)
type ||= [:logo, :dancing].sample
case type
when :logo
- File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
- require "rdoc"
- RDoc::RI::Driver.new.page do |io|
- IO.copy_stream(f, io)
- end
+ require "rdoc"
+ RDoc::RI::Driver.new.page do |io|
+ io.write easter_egg_logo(:large)
end
when :dancing
begin