123456789_123456789_123456789_123456789_123456789_

Module: IRB

Relationships & Source Files
Namespace Children
Modules:
Classes:
Exceptions:
Defined in: lib/irb/help.rb,
lib/irb.rb,
lib/irb/color.rb,
lib/irb/color_printer.rb,
lib/irb/command.rb,
lib/irb/completion.rb,
lib/irb/context.rb,
lib/irb/debug.rb,
lib/irb/default_commands.rb,
lib/irb/easter-egg.rb,
lib/irb/frame.rb,
lib/irb/helper_method.rb,
lib/irb/history.rb,
lib/irb/init.rb,
lib/irb/input-method.rb,
lib/irb/inspector.rb,
lib/irb/locale.rb,
lib/irb/nesting_parser.rb,
lib/irb/notifier.rb,
lib/irb/output-method.rb,
lib/irb/pager.rb,
lib/irb/ruby-lex.rb,
lib/irb/source_finder.rb,
lib/irb/statement.rb,
lib/irb/version.rb,
lib/irb/workspace.rb,
lib/irb/command/backtrace.rb,
lib/irb/command/base.rb,
lib/irb/command/break.rb,
lib/irb/command/catch.rb,
lib/irb/command/cd.rb,
lib/irb/command/chws.rb,
lib/irb/command/context.rb,
lib/irb/command/continue.rb,
lib/irb/command/copy.rb,
lib/irb/command/debug.rb,
lib/irb/command/delete.rb,
lib/irb/command/disable_irb.rb,
lib/irb/command/edit.rb,
lib/irb/command/exit.rb,
lib/irb/command/finish.rb,
lib/irb/command/force_exit.rb,
lib/irb/command/help.rb,
lib/irb/command/history.rb,
lib/irb/command/info.rb,
lib/irb/command/internal_helpers.rb,
lib/irb/command/irb_info.rb,
lib/irb/command/load.rb,
lib/irb/command/ls.rb,
lib/irb/command/measure.rb,
lib/irb/command/next.rb,
lib/irb/command/pushws.rb,
lib/irb/command/show_doc.rb,
lib/irb/command/show_source.rb,
lib/irb/command/step.rb,
lib/irb/command/subirb.rb,
lib/irb/command/whereami.rb,
lib/irb/debug/ui.rb,
lib/irb/ext/change-ws.rb,
lib/irb/ext/eval_history.rb,
lib/irb/ext/loader.rb,
lib/irb/ext/multi-irb.rb,
lib/irb/ext/tracer.rb,
lib/irb/ext/use-loader.rb,
lib/irb/ext/workspaces.rb,
lib/irb/helper_method/base.rb,
lib/irb/helper_method/conf.rb,
lib/irb/lc/error.rb,
lib/irb/lc/ja/error.rb

Overview

history.rb - by Keiju ISHITSUKA(keiju@ruby-lang.org)

Constant Summary

Class Method Summary

Class Method Details

CurrentContext

This method is for internal use only.

The current ::IRB::Context of the session, see conf

irb
irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"

See additional method definition at file lib/irb.rb line 39.

[ GitHub ]

  
# 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 ||= [:, :dancing].sample
  case type
  when :
    Pager.page do |io|
      logo_type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large
      io.write (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 (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.

[ GitHub ]

  
# File 'lib/irb.rb', line 66

def irb_abort(irb, exception = Abort) # :nodoc:
  irb.context.thread.raise exception, "abort then interrupt!"
end

.irb_exit

This method is for internal use only.

Quits irb

[ GitHub ]

  
# 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

[ GitHub ]

  
# File 'lib/irb.rb', line 44

def start(ap_path = nil)
  STDOUT.sync = true
  $0 = File::basename(ap_path, ".rb") if ap_path

  setup(ap_path)

  if @CONF[:SCRIPT]
    irb = Irb.new(nil, @CONF[:SCRIPT])
  else
    irb = Irb.new
  end
  irb.run(@CONF)
end