How would I go about getting the orientation of my current screen in Windows using Ruby?

Viewed 23

I am using Ruby 3.0 and I would like to know how to check if the users screen is portrait-flipped (or upside down) assuming the user only has 1 screen.

1 Answers

I would say that since Ruby is a server-side language, you will need to rely on a browser-side tech first, such as JavaScript, as getting the size and orientation of a screen would be done browser-side.

There are probably JS libraries for that if you prefer, but here are some docs to detect device orientation on some browsers:

With the value obtained in JS, you would then do some AJAX call to your ruby code to send the value to the backend. (you would create a API controller that receive orientation data and update your ruby objects, or whatever you want to do with the orientation)

I hope this is helping you go in the right direction!

Related