Page 1 of 1

Ruby Array Formating

Posted: Fri Mar 17, 2017 5:24 am
by aronb
Hi,

I created a Ruby Circle Class that seems to work. I created an array of circles, that seems to work as well... However I don't know how to format the output to an external array in one of two ways. :oops:

1 - With all of the circle data array info in one comma delimited array
2 - With each element in its own array

Here is my schematic, (with notes) any help would be appreciated please :)

Ruby_Circle_Array.fsm
Ruby Circle Array and Class
(1.86 KiB) Downloaded 940 times


Thank You,

Aron

Re: Ruby Array Formating

Posted: Fri Mar 17, 2017 12:30 pm
by tulamide
Get all data from one type into an array:

Code: Select all

xpos = []
cir.map { |e| xpos << e.xposition }      
output 'data', xpos


You'd do the very same to each of your class' values (e.g. e.yposition, or e.color)

Getting an array of arrays is more tricky, since you don't have an array of arrays output. Instead you would translate it to a string and output a string.

Since I don't know what you expect the exported values to be used for, I can't tell more.

Re: Ruby Array Formating

Posted: Sat Mar 18, 2017 3:26 am
by aronb
tulamide,

Thanks - that got me going to the next part! :D !

I almost feel I am FINALLY learning a bit of Ruby :oops: Its a long road when you mind is a bit older :shock:

Aron