module

SpintaxParser

A mixin to parse "spintax", a text format used for automated article generation. Can handle nested spintax, and can count the total number of unique variations.

class String
  include SpintaxParser
end

Constants

SPINTAX_PATTERN = /\{([^{}]*)\}/
VERSION = "0.1.0"

Instance methods

count_spintax_variations

Returns count of variations for spintax.

"{Fred|George} is {blue|red}.".count_spintax_variations
 > 4
Source
unspin(random = Random::DEFAULT)

Returns the unspun version of some spintext.

"{Fred|George} is {blue|red}.".unspin
 > "Fred is red."
Source