class Ppl::Application::Router
Attributes
aliases[RW]
default[RW]
external_command[RW]
Public Class Methods
new(command_suite)
click to toggle source
# File lib/ppl/application/router.rb, line 7 def initialize(command_suite) @command_suite = command_suite @aliases = {} end
Public Instance Methods
route(argument)
click to toggle source
# File lib/ppl/application/router.rb, line 12 def route(argument) command = @command_suite.find_command(argument) if command.nil? && @aliases.has_key?(argument) if is_bang_alias?(argument) command = create_external_command(argument) else command = @command_suite.find_command(@aliases[argument]) end end if command.nil? && !@default.nil? command = @command_suite.find_command(@default) end return command end
Private Instance Methods
create_external_command(key)
click to toggle source
# File lib/ppl/application/router.rb, line 34 def create_external_command(key) @external_command.name = key @external_command.command = @aliases[key][1..-1] @external_command end
is_bang_alias?(key)
click to toggle source
# File lib/ppl/application/router.rb, line 30 def is_bang_alias?(key) @aliases[key].match(/^!/) end