Class: Pry::BlockCommand

Inherits:
Command show all
Defined in:
lib/pry/command.rb

Overview

A super-class for Commands that are created with a single block.

This class ensures that the block is called with the correct number of arguments and the right context.

Create subclasses using CommandSet#command.

Constant Summary

Constant Summary

Constants inherited from Command

Command::VOID_VALUE

Instance Attribute Summary

Attributes inherited from Command

#_pry_, #arg_string, #captures, #command_block, #command_set, #context, #eval_string, #output, #target

Instance Method Summary (collapse)

Methods inherited from Command

banner, #block, #call_safely, #call_with_hooks, #check_for_command_collision, #command_name, #command_options, command_regex, #commands, convert_to_regex, #correct_arg_arity, #dependencies_met?, #description, group, hooks, #initialize, inspect, #interpolate_string, #match, match_score, matches?, #name, name, options, #pass_block, #process_line, #run, subclass, #target_self, #text, #tokenize, #void

Methods included from Helpers::CommandHelpers

#absolute_index_number, absolute_index_number, absolute_index_range, #absolute_index_range, blocking_flag_for_editor, #blocking_flag_for_editor, command_error, #command_error, editor_name, #editor_name, file_and_line_from_binding, #file_and_line_from_binding, #get_method_or_raise, get_method_or_raise, #invoke_editor, invoke_editor, make_header, #make_header, one_index_number, #one_index_number, one_index_range, #one_index_range, one_index_range_or_number, #one_index_range_or_number, #render_output, render_output, #restrict_to_lines, restrict_to_lines, #start_line_syntax_for_editor, start_line_syntax_for_editor, #temp_file, temp_file, #unindent, unindent

Methods included from Helpers::OptionsHelpers

method_object, #method_object, method_options, #method_options

Methods included from Helpers::BaseHelpers

colorize_code, #colorize_code, command_dependencies_met?, #command_dependencies_met?, #create_command_stub, create_command_stub, #find_command, find_command, #gem_installed?, gem_installed?, #heading, heading, highlight, #highlight, jruby?, #jruby?, #lesspipe, lesspipe, #mri_18?, mri_18?, mri_19?, #mri_19?, #not_a_real_file?, not_a_real_file?, #page_size, page_size, #rbx?, rbx?, set_file_and_dir_locals, #set_file_and_dir_locals, silence_warnings, #silence_warnings, simple_pager, #simple_pager, stagger_output, #stagger_output, #stub_proc, stub_proc, #use_ansi_codes?, use_ansi_codes?, #windows?, windows?

Constructor Details

This class inherits a constructor from Pry::Command

Instance Method Details

- (Object) call(*args)

Call the block that was registered with this command.

Parameters:

  • *String

    the arguments passed

Returns:

  • Object the return value of the block



423
424
425
# File 'lib/pry/command.rb', line 423

def call(*args)
  instance_exec(*correct_arg_arity(block.arity, args), &block)
end

- (Object) help



427
428
429
# File 'lib/pry/command.rb', line 427

def help
  "#{command_options[:listing].to_s.ljust(18)} #{description}"
end