Extract code from command to a ruby class