desc "knows", I18n.t("scripts.knows") respond(/knows/i) do say KnownFormmater.new(know_how).format end class KnownFormmater def initialize(actions) @actions = actions @max_size = @actions.keys.map(&:length).max end def format @actions.inject("```\n") { |_message, command| _message << format_command(command) + "\n" } + "```" end private def name(command_name) pad = @max_size - command_name.length (" " * pad) + command_name end def format_command(command) message = name command.first message << ": #{command.last}" if command.last message end end