ruby variables in own class

For general discussion related FlowStone
Post Reply
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

ruby variables in own class

Post by stw »

Since i went into the challenge of trying to deal with ruby i run into several problems here and there.
Most have to do with real understanding of all that object relating stuff and doing the right things at the right place concerning this matter.
Anyway...i'd like to do something like that:

capture.jpg
capture.jpg (38.28 KiB) Viewed 13752 times

Whatever i tried so far (and it was a lot) i always get that nil error. AFAIK the prob is that the input doesn't get through to the class method? What do i have to do? I guess it's a simple question but i don't get it... :roll:
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

Re: ruby variables in own class

Post by stw »

Nevermind... i got it. Must have done something wrong before but now it works with class variables. Constant works as well...
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ruby variables in own class

Post by tester »

As far I remember, there might be something with copy/paste order and parrent folders (modules) for classes.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
User avatar
chackl
Posts: 233
Joined: Tue Aug 17, 2010 8:46 pm
Location: Austria / Salzburg

Re: ruby variables in own class

Post by chackl »

This may not be a problem with the paste-Order

Defining a Class in a Rubyedit is OK - But getting data from the rubyEdit with the classdefinition is not OK and not that easy ... OK ...

Some smart guy told me some time ago "in ruby everything is an Object" :D (THX trogluddite) - well and if you think about that and combine this with global variables ($varname) then you have some power to get it working ;)

An example in in the file below

Kind Regards, C.Hackl
Attachments
global class data.fsm
(722 Bytes) Downloaded 919 times
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

Re: ruby variables in own class

Post by stw »

Yes, that's how i did it. Thanks for your help. And as i mentioned it also works with class variables and constants. It doesn't necessarily have to ba a global var.
User avatar
chackl
Posts: 233
Joined: Tue Aug 17, 2010 8:46 pm
Location: Austria / Salzburg

Re: ruby variables in own class

Post by chackl »

Maybe you could post a short example?

I know that i do not have the best solution :D - but maybe we could find a better :D
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

Re: ruby variables in own class

Post by stw »

like this...

vartest.fsm
(464 Bytes) Downloaded 903 times
Post Reply