User Guide
Ruby Component
Persistence
The Ruby component saves its state. If you save a schematic with a Ruby component in it then when you load it back the @ins and @outs
arrays are restored to exactly how they were before. This ensures that the component maintains its state at all times.
The only exception to this is bitmaps. Because bitmaps can be very large these are not automatically saved as part of the input and output
arrays. If you want to restore a bitmap after loading use the After Load component to trigger a refresh of any input bitmap. In addition you
may want to add an After Duplicate component too so that the bitmap refreshes when you copy and paste.
User State Management
If you have your own data that you want to save with a Ruby component then you can implement the saveState and loadState methods:
def loadState v
end
def saveState
end
The way this works is really simple. In the saveState method you return a Ruby object that encapsulates all the data that you want to save. It
could be a string or an array say if you have lots of data or it could just be a simple value.
When you save your schematic the saveState method is called by FlowBotics Studio and the state of your Rub component is saved as well.
When you open your schematic again FlowBotics Studio calls the loadState method and passes it the data you returned in the saveState
method. All you need to do is use this data to restore your component state back to how it was.
Here's a little example of how this works. It shows a counter that retains its current value when saved:
113 of 212