Ruby Array Formating

For general discussion related FlowStone
Post Reply
User avatar
aronb
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA
Contact:

Ruby Array Formating

Post 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
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby Array Formating

Post 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.
"There lies the dog buried" (German saying translated literally)
User avatar
aronb
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA
Contact:

Re: Ruby Array Formating

Post 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
Post Reply