mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
add a few more Pry::Method-style methods to Pry::Command
also expose command_name method as a class method on Pry::Command so we can retrieve the command name from the classes returns from Pry.commands.find_command()
This commit is contained in:
parent
14f7f86b8b
commit
4ca1fa78a7
1 changed files with 15 additions and 1 deletions
|
|
@ -61,6 +61,16 @@ class Pry
|
|||
def source_location
|
||||
block.source_location
|
||||
end
|
||||
|
||||
def source_file
|
||||
Array(block.source_location).first
|
||||
end
|
||||
alias_method :file, :source_file
|
||||
|
||||
def source_line
|
||||
Array(block.source_location).last
|
||||
end
|
||||
alias_method :line, :source_line
|
||||
end
|
||||
|
||||
# Make those properties accessible to instances
|
||||
|
|
@ -69,7 +79,7 @@ class Pry
|
|||
def description; self.class.description; end
|
||||
def block; self.class.block; end
|
||||
def command_options; self.class.options; end
|
||||
def command_name; command_options[:listing]; end
|
||||
def command_name; self.class.command_name; end
|
||||
def source; self.class.source; end
|
||||
def source_location; self.class.source_location; end
|
||||
|
||||
|
|
@ -82,6 +92,10 @@ class Pry
|
|||
name
|
||||
end
|
||||
|
||||
def command_name
|
||||
self.options[:listing]
|
||||
end
|
||||
|
||||
# Create a new command with the given properties.
|
||||
# @param [String, Regex] match The thing that triggers this command
|
||||
# @param [String] description The description to appear in `help`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue