If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby Array Formating
3 posts
• Page 1 of 1
Ruby Array Formating
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.
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
Thank You,
Aron
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.
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
Thank You,
Aron
-
aronb - Posts: 154
- Joined: Sun Apr 17, 2011 3:08 am
- Location: Florida, USA
Re: Ruby Array Formating
Get all data from one type into an array:
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.
- 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)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Array Formating
tulamide,
Thanks - that got me going to the next part! !
I almost feel I am FINALLY learning a bit of Ruby Its a long road when you mind is a bit older
Aron
Thanks - that got me going to the next part! !
I almost feel I am FINALLY learning a bit of Ruby Its a long road when you mind is a bit older
Aron
-
aronb - Posts: 154
- Joined: Sun Apr 17, 2011 3:08 am
- Location: Florida, USA
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 55 guests