Comparing identical values in Ruby

For general discussion related FlowStone
Post Reply
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Comparing identical values in Ruby

Post 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?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Comparing identical values in Ruby

Post by KG_is_back »

You mean something like this?
Attachments
ifequaltoprev.fsm
(337 Bytes) Downloaded 762 times
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Re: Comparing identical values in Ruby

Post 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 :)
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Re: Comparing identical values in Ruby

Post 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 :?: )
Post Reply