Page 1 of 1

Comparing identical values in Ruby

Posted: Sat Oct 18, 2014 6:55 am
by kortezzzz
Hi,
Once again, a Ruby challenge:
I need a simple ruby module with 1 in-1out floats that responds to the incoming data whenever a value is sent to it, even if the sent value has sent twice in raw. For instance, if i press a key that sends the float value "2" twice, the module should recognize that. On the first press, it should output "2", but on the second, it should output "3", if any other new key is pressed ( even if its "2" again!) after the the double press, then it will output the new value, untill this value is double-pressed again. Any suggestion?

Re: Comparing identical values in Ruby

Posted: Sat Oct 18, 2014 8:51 am
by KG_is_back
You mean something like this?

Re: Comparing identical values in Ruby

Posted: Sat Oct 18, 2014 7:46 pm
by kortezzzz
Sorry for the late respond. Just tested it; Works amazing! :)
Thanks a lot KG. And from 1 example to another, I'm slowly learning how Ruby's logic translated into an actual code.
Really great :)

Re: Comparing identical values in Ruby

Posted: Sat Oct 18, 2014 9:33 pm
by kortezzzz
Last principle question for today: how do we block values in ruby from passing out? Lets say we have a code with 1 midi in+1float in and1 midi out, and we want to completely block the midi signal from passing out when the float value =1. How do we do it? As far as i understand, "else 0" doesnt blocks, but just sends a zero to the output (bad solution, dont it :?: )