CD-RUM CD-RUM - 7 months ago 73
Ruby Question

Ruby: reverse calculation or spreadsheet function

I've got a module that calculates about 150-200 values. Once it's done, I want the ability to edit one or some of the results—which may or may not be one of the original, non-calculated values—and have the other results update, like the functionality of a spreadsheet.

The problem is I really don't know where to start. The module's code looks largely like this:

if @user.override > 0
h[:floor] += (@user.override / h[:size]) * 0.03

if @user.other_override > 0
h[:floor] += (@user.other_override / h[:size]) * 0.03

And is quite chronological, making this task even tougher.

Is there any approach here that'll work? I can barely wrap my head around how it might, other than to leverage an actual spreadsheet into my app.


What you are looking for is called "Reactive Programming". Many languages have an implementation of the ReactiveX framework, so does Ruby: RxRuby