Module: IRB::Command
- Defined in:
- lib/irb/command/ls.rb,
lib/irb/command.rb,
lib/irb/command/cd.rb,
lib/irb/command/base.rb,
lib/irb/command/chws.rb,
lib/irb/command/copy.rb,
lib/irb/command/edit.rb,
lib/irb/command/exit.rb,
lib/irb/command/help.rb,
lib/irb/command/info.rb,
lib/irb/command/load.rb,
lib/irb/command/next.rb,
lib/irb/command/step.rb,
lib/irb/command/break.rb,
lib/irb/command/catch.rb,
lib/irb/command/debug.rb,
lib/irb/command/delete.rb,
lib/irb/command/finish.rb,
lib/irb/command/pushws.rb,
lib/irb/command/subirb.rb,
lib/irb/command/context.rb,
lib/irb/command/history.rb,
lib/irb/command/measure.rb,
lib/irb/command/continue.rb,
lib/irb/command/irb_info.rb,
lib/irb/command/show_doc.rb,
lib/irb/command/whereami.rb,
lib/irb/default_commands.rb,
lib/irb/command/backtrace.rb,
lib/irb/command/force_exit.rb,
lib/irb/command/disable_irb.rb,
lib/irb/command/show_source.rb,
lib/irb/command/internal_helpers.rb more...
Overview
:stopdoc:
Defined Under Namespace
Modules: RubyArgsExtractor Classes: Backtrace, Base, Break, CD, Catch, ChangeWorkspace, CommandArgumentError, Context, Continue, Copy, CurrentWorkingWorkspace, Debug, DebugCommand, Delete, DisableIrb, Edit, Exit, Finish, ForceExit, Foreground, Help, History, Info, IrbCommand, IrbInfo, Jobs, Kill, Load, LoaderCommand, Ls, Measure, MultiIRBCommand, Next, PopWorkspace, PushWorkspace, Require, ShowDoc, ShowSource, Source, Step, Whereami, Workspaces
Constant Summary collapse
- Nop =
:nodoc:
Base
- NO_OVERRIDE =
0
- OVERRIDE_PRIVATE_ONLY =
0x01
- OVERRIDE_ALL =
0x02
Class Attribute Summary collapse
-
.commands ⇒ Object
readonly
Returns the value of attribute commands.
Class Method Summary collapse
-
._register_with_aliases(name, command_class, *aliases) ⇒ Object
This API is for IRB’s internal use only and may change at any time.
- .all_commands_info ⇒ Object
- .command_names ⇒ Object
- .command_override_policies ⇒ Object
- .execute_as_command?(name, public_method:, private_method:) ⇒ Boolean
-
.extract_ruby_args(*args, **kwargs) ⇒ Object
:nodoc:.
-
.load_command(command) ⇒ Object
Convert a command name to its implementation class if such command exists.
-
.register(name, command_class) ⇒ Object
Registers a command with the given name.
Class Attribute Details
Class Method Details
permalink ._register_with_aliases(name, command_class, *aliases) ⇒ Object
This API is for IRB’s internal use only and may change at any time. Please do NOT use it.
44 45 46 |
# File 'lib/irb/default_commands.rb', line 44 def _register_with_aliases(name, command_class, *aliases) @commands[name.to_sym] = [command_class, aliases] end |
permalink .all_commands_info ⇒ Object
[View source]
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/irb/default_commands.rb', line 48 def all_commands_info user_aliases = IRB.CurrentContext.command_aliases.each_with_object({}) do |(alias_name, target), result| result[target] ||= [] result[target] << alias_name end commands.map do |command_name, (command_class, aliases)| aliases = aliases.map { |a| a.first } if additional_aliases = user_aliases[command_name] aliases += additional_aliases end display_name = aliases.shift || command_name { display_name: display_name, description: command_class.description, category: command_class.category } end end |
permalink .command_names ⇒ Object
[View source]
87 88 89 |
# File 'lib/irb/default_commands.rb', line 87 def command_names command_override_policies.keys.map(&:to_s) end |
permalink .command_override_policies ⇒ Object
[View source]
70 71 72 73 74 |
# File 'lib/irb/default_commands.rb', line 70 def command_override_policies @@command_override_policies ||= commands.flat_map do |cmd_name, (cmd_class, aliases)| [[cmd_name, OVERRIDE_ALL]] + aliases end.to_h end |
permalink .execute_as_command?(name, public_method:, private_method:) ⇒ Boolean
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/irb/default_commands.rb', line 76 def execute_as_command?(name, public_method:, private_method:) case command_override_policies[name] when OVERRIDE_ALL true when OVERRIDE_PRIVATE_ONLY !public_method when NO_OVERRIDE !public_method && !private_method end end |
permalink .extract_ruby_args(*args, **kwargs) ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/irb/command/base.rb', line 12 def extract_ruby_args(*args, **kwargs) # :nodoc: throw :EXTRACT_RUBY_ARGS, [args, kwargs] end |
permalink .load_command(command) ⇒ Object
Convert a command name to its implementation class if such command exists
92 93 94 95 96 97 98 99 100 |
# File 'lib/irb/default_commands.rb', line 92 def load_command(command) command = command.to_sym commands.each do |command_name, (command_class, aliases)| if command_name == command || aliases.any? { |alias_name, _| alias_name == command } return command_class end end nil end |
permalink .register(name, command_class) ⇒ Object
Registers a command with the given name. Aliasing is intentionally not supported at the moment.
18 19 20 |
# File 'lib/irb/command.rb', line 18 def register(name, command_class) @commands[name.to_sym] = [command_class, []] end |