Commerce Custom Shipping Methods via Plugin
Ok, so what you're doing is returning a new instance of a shipping method class - this class must meet the Shipping Method interface - documented here: https://craftcommerce.com/docs/shipping-methods#shipping-method-interface

That is, you must implement each of those functions as defined by the interface in your shipping method class.

You'd define this class in a file of it's own named after the class, and in your base plugin file you require this class definition to bring it in to scope.

The same goes for your shipping rules - you again create a class that meets the interface and then require that in your main plugin file (or wherever you need to access the rule).