1
0
Fork 0
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:
John Mair 2012-12-02 03:57:17 +01:00
parent 14f7f86b8b
commit 4ca1fa78a7

View file

@ -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`