Module: IRB
Overview
history.rb - by Keiju ISHITSUKA(keiju@ruby-lang.org)
Constant Summary
-
ExtendCommand =
# File 'lib/irb/default_commands.rb', line 257Command -
IRBRC_EXT =
Internal use only
# File 'lib/irb/init.rb', line 409"rc" -
TOPLEVEL_BINDING =
# File 'lib/irb/workspace.rb', line 9binding -
VERSION =
Internal use only
# File 'lib/irb/version.rb', line 8"1.17.0"
Class Method Summary
- .easter_egg(type = nil)
- .easter_egg_logo(type)
-
.start(ap_path = nil)
Initializes IRB and creates a new
Irb.irbobject at the TOPLEVEL_BINDING - CurrentContext Internal use only
- .inspect Internal use only
-
.irb_abort(irb, exception = Abort)
Internal use only
Aborts then interrupts irb.
-
.irb_exit
Internal use only
Quits irb.
Class Method Details
CurrentContext
This method is for internal use only.
# File 'lib/irb/ext/multi-irb.rb', line 175
def CurrentContext # :nodoc: conf[:MAIN_CONTEXT] end
.easter_egg(type = nil)
[ GitHub ]# File 'lib/irb/easter-egg.rb', line 109
private def easter_egg(type = nil) print "\e[?1049h" type ||= [:logo, :dancing].sample case type when :logo 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 interrupted = false prev_trap = trap("SIGINT") { interrupted = true } canvas = Canvas.new(Reline.get_screen_size) otio = Reline::IOGate.prep Reline::IOGate.set_winch_handler do canvas = Canvas.new(Reline.get_screen_size) end ruby_model = RubyModel.new print "\e[?25l" # hide cursor (0..).each do |i| 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 break if interrupted end rescue Interrupt ensure Reline::IOGate.deprep(otio) print "\e[?25h" # show cursor trap("SIGINT", prev_trap) end end ensure print "\e[0m\e[?1049l" end
.easter_egg_logo(type)
[ GitHub ]# File 'lib/irb/easter-egg.rb', line 101
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
.inspect
This method is for internal use only.
[ GitHub ]
# File 'lib/irb/init.rb', line 19
def @CONF.inspect array = [] for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name} case k when :MAIN_CONTEXT, :__TMP__EHV__ array.push format("CONF[:%s]=...myself...", k.id2name) when :PROMPT s = v.collect{ |kk, vv| ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"} format(":%s=>{%s}", kk.id2name, ss.join(", ")) } array.push format("CONF[:%s]={%s}", k.id2name, s.join(", ")) else array.push format("CONF[:%s]=%s", k.id2name, v.inspect) end end array.join("\n") end
.irb_abort(irb, exception = Abort)
This method is for internal use only.
Aborts then interrupts irb.
Will raise an ::IRB::Abort exception, or the given exception.
.irb_exit
This method is for internal use only.
Quits irb
# File 'lib/irb.rb', line 59
def irb_exit(*) # :nodoc: throw :IRB_EXIT, false end
.start(ap_path = nil)
Initializes IRB and creates a new Irb.irb object at the TOPLEVEL_BINDING