class Discryb::ComplimentTemplate

Overview

A ComplimentTemplate contains templates that are used to form compliment strings.

The top-level compliments are in #base_templates, and they are instantiated using the subtemplates and strings in #subtemplates.

Defined in:

discryb/compliment_template.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(base_templates : Array(String), subtemplates : Hash(String, Array(String)), seed = nil) #

Creates a new ComplimentTemplate with the given base templates and subtemplates


[View source]

Class Method Detail

def self.from_yaml(string_or_io : String | IO) #

Creates a new ComplimentTemplate from the given YAML string or IO


[View source]

Instance Method Detail

def all_instantiations #

Outputs all possible instantiations of all base templates


[View source]
def base_templates : Array(String) #

[View source]
def generate_compliment #

Randomly generates a compliment from the base templates


[View source]
def instantiate_template(template : String) #

Randomly turns a compliment template into a concrete string through repeated substitution


[View source]
def subtemplates : Hash(String, Array(String)) #

[View source]
def valid? #

Returns true if all templates will instantiate into concrete strings, otherwise returns false


[View source]