Ruby nuby needs help
Posted: Tue Oct 22, 2013 4:41 am
I wrote a Ruby module to replace some green math just to learn a bit... after discovering 1/12 = 0 but 1.0/12 = 0.083333333 things went more or less as expected.
But when I reopened the schematic it was flagging a Ruby error... I couldn't figure it out as it looked OK and had been working when I saved... then I discovered if it clicked on each of the inputs it would resolve the error...
Here's the code the module contains: (It's for the fret x offsets on a guitar scale display.)
Can anyone sort me out on this?
But when I reopened the schematic it was flagging a Ruby error... I couldn't figure it out as it looked OK and had been working when I saved... then I discovered if it clicked on each of the inputs it would resolve the error...
Here's the code the module contains:
Code: Select all
def _Nx12thRoot2Inv(x)
1.0/2**(x*(1.0/12))
end
scaleLength = (@fbWidth - @nutThickness - 0.5*@fretWidth )
scaleLength = scaleLength * (1/(1 - _Nx12thRoot2Inv(@Nfrets)))
output scaleLength * (1 - _Nx12thRoot2Inv(@fretNumber)) + @xOffset + @nutThickness
Can anyone sort me out on this?