Hi Ruby,
Here's an example of the transform method:
$step.move(-30d,0)
.transform($capsule -> {
$capEnd = $capsule.endKey()
capsule($capEnd-$durationsignal.valueAt($capEnd), $capEnd)
})
Some notes about this:
You can only make a capsule that's within the capsule that goes into the transform. That's why I started with the .move(-30d,0). Basically what I'm doing there is saying I'd like to keep the end of the capsule (because that's what your new capsule will be based off of) and in worst case scenario, the capsule would be 30 days long so I move it 30 days to start. Adjust this as necessary to match your use case. Then inside the transform I'm saying make a new capsule that ends where my previous capsule ended and starts the amount of time of the $durationsignal at the point where my original capsule ended before the end of the capsule.
Hopefully this makes sense, but let me know if you have any questions or difficulties with implementing this.