Sha256: 73f4b070d7ed8e2b1c05271f2e213e5684d970b6ddb9d7fb53766deb397b616c

Contents?: true

Size: 370 Bytes

Versions: 1

Compression:

Stored size: 370 Bytes

Contents

module Glueckskeks
  class Substitutor
    def self.replace(str, corpus)
      /.*<(?<type>[^>]*)>.*/ =~ str
      if type
        if !(corpus.has_key? type)
          Glueckskeks.logger.error "No corpus entry for #{type} found"
        end
        replace_with =  corpus[type].sample
        str.gsub!("\<#{type}\>", replace_with)
      end
      str
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glueckskeks-0.1.1 lib/glueckskeks/substitutor.rb