class Ruboty::HelpQuery::Actions::Help
Public Instance Methods
call()
click to toggle source
# File lib/ruboty/help_query/actions/help.rb, line 7 def call message.reply(help) end
Private Instance Methods
help()
click to toggle source
# File lib/ruboty/help_query/actions/help.rb, line 13 def help Ruboty.actions.reject(&:hidden?) .select { |action|action.pattern.to_s =~ /#{message[:query]}/ } .sort .map do |action| prefix = '' prefix << message.robot.name << ' ' unless action.all? pattern_format = "%-#{pattern_max_length + prefix.size}s" pattern_text = "#{prefix}#{action.pattern.inspect}" "#{pattern_format} - #{action.description}" % pattern_text end.join("\n") rescue => e "Error: #{e.message}" end
pattern_max_length()
click to toggle source
# File lib/ruboty/help_query/actions/help.rb, line 28 def pattern_max_length Ruboty.actions.map { |action| action.pattern.inspect }.map(&:size).max end