1

Using Math Functions in Ruby Scripts

I am looking to calculate a square root in a measure I'm writing, but the math.sqrt() method does not work. Is there a way to include Ruby's Math module when writing measures or is there another way to use the higher level math functions?

Alec's avatar
139
Alec
asked 2015-08-11 14:14:22 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2015-11-07 13:47:22 -0500
edit flag offensive 0 remove flag close merge delete

Comments

@Alec I re-tagged your post to include the existing openstudio-measure tag, rather than openstudio-measures

ericringold's avatar ericringold (2015-08-11 14:24:54 -0500) edit
add a comment see more comments

2 Answers

6

I think the issue may be that the Math module needs to be capitalized, try

Math.sqrt(4)

http://ruby-doc.org/core-2.0.0/Math.h...

macumber's avatar
12k
macumber
answered 2015-08-11 14:20:59 -0500
edit flag offensive 0 remove flag delete link

Comments

It looks like this did it. Thank you.

Alec's avatar Alec (2015-08-11 14:29:43 -0500) edit
add a comment see more comments
2

I'm guessing you would do something like...

require math

...at the top of your measure.

It's also worth a search of your local BCL folder for "math" to see how it's used elsewhere.

MatthewSteen's avatar
10.1k
MatthewSteen
answered 2015-08-11 14:19:59 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments