In stylus is it possible to change a variable based on the class of the parent?

I'm trying to create a variable which will change the colours from white to black depending on it being inside something with an '.inverted' class. I only want the variable to change though (so I can use it for any colour-based property).

If it were written in jQuery it would look like this:

$lightswitch = ($(this).parents('.inverse')) ? '#000' : '#fff';

I imagine there is a mixin or something I could write for this but I can't quite get my head around how to do it.