ContentSpinning
is a ruby library made to spin some text.
It manages nested spinning.
"Hi {there|you}! I'm {efficient|productive}.".spin
# or
ContentSpinning.spin("Hi {there|you}! I'm {efficient|productive}.")
returns this array :
[
"Hi there! I'm efficient.",
"Hi there! I'm productive.",
"Hi you! I'm efficient.",
"Hi you! I'm productive."
]
gem install content_spinning
Calculating the number of possibilities:
> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").count
4
Generating:
> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").spin
[
"Hi there! I'm efficient.",
"Hi there! I'm productive.",
"Hi you! I'm efficient.",
"Hi you! I'm productive."
]
Beware, spins being combinatory, generating all the spins could be quite long.
There is no guaranty of unicity among the results returned (this is random). If you ask for a limit greater than the number of possibilities, this returns all the possibilities.
> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").spin(limit: 2)
[
"Hi there! I'm efficient.",
"Hi you! I'm productive."
]
> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").spin(limit: 500)
[
"Hi there! I'm efficient.",
"Hi there! I'm productive.",
"Hi you! I'm efficient.",
"Hi you! I'm productive."
]
A few things to do :
- Executable