How to rotate a cube on its own edges ?

I amtrying to make a game and in this game there is a cube which moves around by up down left and right arrow keys. I can rotate the cube but still couln’t find out how to rotate it on different edges.

Quite simple! Translate the cube so that its edge coincide with a certain axis, and then rotate around that axis.

Thanks for your answer. That was my initial thoughts but i hoped something more simpler : ) Since i will use 4 different direction i beleive i just need to know orientation of the cube so this is my other question, how can i get the orientation of the object ?