Measure tool ruler in javascript
An image is open and a fragment is being measured using the ruler tool:

I want to resize the image to real scale through a simple javascript using the value of the measurement that appears in the information tab. My problem is that I don't know how to get the value of the rule tool in javascript.
The script is the following:
// =======================================================
var startRulerUnits = app.preferences.rulerUnits
var docRef = app.documents[0]
var w; var h; var r; var measureRulerTool
app.preferences.rulerUnits = Units.CM
measureRulerTool = <<MEASUREMENT IN CENTIMETERS TAKEN BY THE RULER TOOL>>
w= docRef.width / measureRulerTool
h = docRef.height / measureRulerTool
r = 1000
docRef.resizeImage (w, h, r)
app.preferences.rulerUnits = startRulerUnits
// =======================================================Can any expert help me?
Many thanks to the community